
[英]How to ignore application.properties values if profile set without changing to application-default.properties
[英]How to load only profile specific property file and ignore default application.properties?
我有一个普通的spring boot应用程序,在resources
文件夹中有两个属性文件:
application.properties
com.example.prop1=value1
com.example.enableMock=true
application-dev.properties
com.example.prop1=value11
根据com.example.enableMock
是否存在,我有一些逻辑。 问题是即使spring.profiles.active=dev
且应用程序正在获取com.example.enableMock
属性,spring也会加载两个文件。
如何只加载配置文件特定的属性文件?
默认情况下, application.properties
加载任何application-*.properties
因为通过以下方式分享:
application.properties
- > application-dev.properties
- > application-test.properties
如果将default
作为配置文件,则可以解决此问题。 重命名application.properties
为:
application-default.properties
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.