使用spring.config.location与本地配置文件属性不能互补


前言

在启动配置中心的时候,由于配置中心里面的配置,比如git配置等等,在不同的环境中是不一样的,因此需要在外部指定,
刚开始选择使用spring.config.location来指定外部配置文件,如:
-Dspring.config.location=C:\\Users\\XB\Desktop\\config\\config-test.yml

结果config-test.yml这个文件直接取代了我项目本地的application.yml文件,导致有些本地配置中独有的配置也没有被加载进来。

解决方案

使用spring.config.additional-location替代spring.config.location
-Dspring.config.additional-location=C:\\Users\\XB\Desktop\\config\\config-test.yml

参考

spring.config.location 不互补
Spring Boot Reference Documentation


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM