【转】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