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

 

posted @ 2019-05-31 15:23  super_we  阅读(2171)  评论(0编辑  收藏  举报