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/";