使用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