Spring Boot 配置文件和日志文件放到jar之外

来源:互联网 发布:安装 SQL 2014 编辑:程序博客网 时间:2024/05/17 01:07

1.设置打包jar的时候排除文件

<resources>    <resource>        <directory>src/main/resources</directory>        <excludes>            <exclude>*.properties</exclude>            <exclude>logback.xml</exclude>        </excludes>    </resource></resources>

2.启动的时候传入参数指定位置

java -jar xxx.jar --spring.config.location=D:\springconfig\  --logging.config=D:\springconfig\logback.xml

springboot 默认找配置文件的位置如下
// Note the order is from least to most specific (last one wins)private static final String DEFAULT_SEARCH_LOCATIONS = "classpath:/,classpath:/config/,file:./,file:./config/";

阅读全文
0 0
原创粉丝点击