I would like to remove duplicate dependencies in maven pom.xml.
I would like answers to multiple tools Linux, Notepad++, Netbeans, Intellij ...even...VIM,etc.
example (I can obvious delete but I would like a search replace answer)
`<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>2.7</version>
</dependency>`
Please write the answer locally links can be frustrating if removed. Thanks.
dependency:analyze-duplicate Analyzes the and tags in the pom.xml and determines the duplicate declared dependencies.
mvn dependency:analyze-duplicate
you can use mvn dependency:tree
command to find duplicate dependencies into your project.
Use the <exclusions>
tag into <dependency>
tag of the pom to exclude that duplicate dependencies from maven project.
<dependencies>
<dependency>
<groupId>test.ProjectX</groupId>
<artifactId>ProjectX</artifactId>
<version>2.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>test.ProjectY</groupId>
<artifactId>ProjectY</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Run mvn clean It will tell you your duplicate dependencies. Then delete them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With