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

2022-08-31 13:15:52

我希望我的默认活动配置文件是 if 未设置。production-Dspring.profiles.active

我在我的尝试了以下方法,但它不起作用:application.properties

spring.profiles.default=production

弹簧引导版本 = 1.3.5.发布


答案 1

您在此处要执行的操作是将默认的配置文件(如果未指定注释,则在任何 Bean 上使用的配置文件)设置为 。@Profileproduction

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

spring.profiles.active=production

答案 2

--spring.profiles.active=production

例:

java -jar file.jar --spring.profiles.active=production

推荐