簡體   English   中英

Log4j文件未從Maven構建中排除

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM