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