简体   繁体   中英

How to exclude an xml file in a maven jar dependency

My project uses a jar that contains a file named broker.xml . Also I have a second file with the same name broker.xml in the resource folder. When I run the web application, I get an error "duplicates non mergeable resource broker.xml".

Is there a way to exclude the xml file inside the jar?

Try TrueZIP Maven Plugin, looks like it suits your scenario

<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>

refer to below link for documentation

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

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

Also refer to below stackoverflow link (look at answer from @Andrea) Remove file from dependency jar using maven

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM