在Spring-boot中设置默认的活动配置文件

在Spring-boot中设置默认的活动配置文件

问题描述:

如果未设置-Dspring.profiles.active,我希望我的默认活动配置文件为production.

I want my default active profile to be production if -Dspring.profiles.active is not set.

我在application.properties中尝试了以下操作,但没有用:

I tried the following in my application.properties but it did't work:

spring.profiles.default=production

Spring-boot版本= 1.3.5.RELEASE

Spring-boot version = 1.3.5.RELEASE

您在这里所做的是设置默认的 default 配置文件(如果未指定,该配置文件将在任何bean上使用@Profile注释)为production.

What you are doing here is setting the default default profile (the profile that is used on any bean if you don't specify the @Profile annotation) to be production.

您实际需要做的是设置默认的活动配置文件,如下所示:

What you actually need to do is set the default active profile, which is done like this:

spring.profiles.active=production