在我的 Spring Boot 2 应用程序中,我想加载位于外部路径中的特定属性文件(按配置文件),但我希望它们加载项目中的通用 application.properties 文件:
我的配置文件夹:
D:/config
| -> hello-dev.properties (server.port=7777)
| -> hello-prod.properties (server.port=5555)
在我的本地 application.properties 中:
logging.file=firstLog.log
所以我的目标是使用 dev
profile 启动我的 Spring Boot 应用程序,并将加载 2 个属性(server.port=7777
和 logging.file=firstLog.log
)
我还确信我的外部属性配置文件的前缀是 hello
而不是默认的 application.properties
感谢您的帮助
最佳答案
试试这个:
java -jar myproject.jar --spring.config.additional-location=classpath:/default.properties,classpath:/override.properties
看关于外部化配置的章节: https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
关于java - 如何将外部配置文件属性与 Spring Boot 2 中包含的通用属性一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54398345/