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

时间:2021-01-26 21:37:12   收藏:0   阅读:454

前言

在启动配置中心的时候,由于配置中心里面的配置,比如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

原文:https://www.cnblogs.com/alinainai/p/14331442.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!