maven打包springboot项目,配置文件外置

在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

 

posted @ 2021-08-25 23:01  一沙世界  阅读(789)  评论(0编辑  收藏  举报