簡體   English   中英

如何在 maven jar 依賴項中排除 xml 文件

[英]How to exclude an xml file in a maven jar dependency

我的項目使用一個 jar,其中包含一個名為broker.xml的文件。 此外,我在資源文件夾中還有一個同名的broker.xml文件。 當我運行 Web 應用程序時,出現錯誤“重復不可合並的資源 broker.xml”。

有沒有辦法排除jar內的xml文件?

試試TrueZIP Maven 插件,看起來它適合你的場景

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>truezip-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <id>remove-a-file-in-sub-archive</id>
            <goals>
                <goal>remove</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <fileset>
                    <directory>target/Samplewebapp.war/WEB-INF/lib/someJar.jar</directory>
                    <includes>
                        <include>broker.xml</include>
                    </includes>
                </fileset>
            </configuration>
        </execution>
    </executions>
</plugin>

請參閱以下鏈接以獲取文檔

http://www.mojohaus.org/truezip/truezip-maven-plugin/

http://www.mojohaus.org/truezip/truezip-maven-plugin/remove-mojo.html

另請參閱下面的stackoverflow鏈接(查看@Andrea的回答) 使用maven從依賴jar中刪除文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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