在POM.XML的<build></build>中配置如下:
<resources>
<resource>
<directory>src\main\resources</directory>
<excludes>
<exclude>application.properties</exclude>
<exclude>log4j2.xml</exclude>
</excludes>
</resource>
</resources>
这句话就可以不把配置文件打包到JAR中。
启动方式,指定logging的配置即可。
java -jar hxgw-1.0-SNAPSHOT.jar --logging.config=./log4j2.xml
原文:https://www.cnblogs.com/yoyotl/p/15187415.html