I am creating maven project in which I added many jars. Now I want to delete some jars from project which are unused. But I am not able to identify which are unused. So can any one provide me simple way to identify and remove those unused jar. I saw some solutions but that are not working for me.
Asked
Active
Viewed 8,433 times
2
-
1I have edited your question to remove the parts where you asked for tool suggestions, which would make your question off-topic. – Mark Rotteveel Feb 03 '18 at 13:52
-
Thank you Mark Rotteveel – Null Pointer Feb 03 '18 at 13:56
-
Note that you must add jars using "pom.xml". You cannot use the normal way your IDE adds jar. – Thorbjørn Ravn Andersen Feb 03 '18 at 14:34
-
1Does this answer your question? [Is there a simple way to remove unused dependencies from a maven pom.xml?](https://stackoverflow.com/questions/1517611/is-there-a-simple-way-to-remove-unused-dependencies-from-a-maven-pom-xml) – Darnoj Mar 06 '20 at 08:35
2 Answers
4
First remove unused imports from your source code. In Eclipse it is Source -> Organize Imports. Then you could use the Maven dependency analyzer by running mvn dependency:analyze-only
. It will produce a report identifying, i.a., unused dependencies.

Jonathan Rosenne
- 2,159
- 17
- 27
0
You can use maven dependency:analyze
to detect un used dependencies. But it wont remove anything.
http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html

miskender
- 7,460
- 1
- 19
- 23