Spring Boot配置文件放在jar外部的問題

1. 如果配置了 --spring.config.location , 則啓動會覆蓋classpath:/,classpath:/config/,file:./,file:./config

2. --spring.config.location=file:./   =》屬性文件只會從當前目錄查找,

如果--spring.profiles.active=prod
查找file:./application-prod.properties 和 file:./application.properties ,不會再去classpath加載(jar包裏的)

3. spring boot jar啓動會自動掃描jar所在目錄下的配置和classpath下的配置。

 

官方說明:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章