[英]Log4j file not excluded from Maven build
我在src / main / resources中有一个log4j.xml文件,试图将其从jar文件中排除。 我在父pom文件中具有版本3.0.0的属性。
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/log4j.xml</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<configuration>
<!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
<encoding>UTF-8</encoding>
</configuration>
</plugin>
...
我升级到了maven-jar-plugin的3.0.0版本,并且还将排除项从“ src / main / resources / log4j.xml”改回为“ ** / log4j.xml”,我已将其临时切换为因此,我不确定是否需要同时修复两个矿石。
如果您使用<exclude>**/*log4j*</exclude>
如果您可以接受此模式,则应该可以使用。
请注意文档底部的内容: https : //maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html
请注意,模式必须相对于为插件的classesDirectory参数指定的路径。
根据Maven手册( https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html ),您必须将要包含/排除的文件放在resources
部分。 因此,如果文件位于src / resources上,则配置为:
<project>
...
<name>My Resources Plugin Practice Project</name>
...
<build>
...
<resources>
<resource>
<directory>src/resources</directory>
<excludes>
<exclude>**/log4j.xml</exclude>
</excludes>
</resource>
...
</resources>
...
</build>
...
</project>
希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.