nutzboot 项目打包排除或指定配置文件(夹)

springboot 是一样的 我这里就是从springboot哪里拿过来的 (nutzboot2.x已测试可以使用)

排除指定文件 在pom 文件 build 标签内添加 resources

<build>      
      <resources>
            <resource>
                <filtering>false</filtering>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>log4j2-test.properties</exclude>
                </excludes>
            </resource>
        </resources>
</build>

排除文件夹下的所有文件的话 <exclude>aa/**</exclude>

指定配置文件 

<build>      
      <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <includes>
                    <include>log4j2.properties</include>
                </includes>
            </resource>
        </resources>
</build>

 上面的方法运行编译时也会生效

如果仅打包时生效 需要使用 添加plugin的方式

          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.2</version>
                <configuration>
                    <excludes>
                        <exclude>log4j2-test.properties</exclude>
                    </excludes>
                </configuration>
            </plugin>
log4j2-test.properties 和 log4j2.properties 同时存在会执行 log4j2-test.properties     
如果log4j2-test.properties 不存在的话才会执行log4j2.properties

一般配置文件执行顺序
properties -> yaml -> json -> xml
前面的如果有的话就不会执行后面的
比如 beetl.yaml beetl.xml 会执行beetl.yaml 后面的不会执行 如果beetl.yaml没有的话才会执行beetl.xml
原文地址:https://www.cnblogs.com/rchao/p/11133081.html