使用spring.config.location与本地配置文件属性不能互补 前言 解决方案 参考

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

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

解决方案

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

使用spring.config.location与本地配置文件属性不能互补
前言
解决方案
参考

参考

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