【轉】SpringBoot打包好后,使用外部的配置文件


1、第一種方式手動指定配置文件位置:

java -jar myspring.jar --spring.config.location=D:\JavaSite\config\application.properties

 

2、第二種方式,根據官網介紹放在指定目錄下

SpringApplication loads properties from application.properties files in the following locations and adds them to the Spring Environment:

1、A /config subdirectory of the current directory //  放在jar包同級目錄下的子目錄config
2、The current directory  //與jar包目錄同級
3、A classpath /config package // 大概意思是在classpath下的config目錄
4、The classpath root // classpath中

引用的優先級和上面的順序是一樣的。

 


---------------------
作者:IAMYINWEIJIAN_
來源:CSDN
原文:https://blog.csdn.net/u013845177/article/details/83142106

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM