有没有一种简单的方法可以从maven pom.xml中删除未使用的依赖项? [英] Is there a simple way to remove unused dependencies from a maven pom.xml?
问题描述
我有一个大型的Maven项目,其中包含许多模块和许多pom.xml
文件.该项目已更改,我怀疑pom包含一些不必要的依赖项.有没有从pom删除任何未使用的依赖项的命令?
I have a large Maven project with many modules and many pom.xml
files. The project has changed and I suspect the pom's contain some unnecessary dependencies. Is there is a command which removes any unused dependencies from a pom?
推荐答案
Maven依赖插件将有所帮助,尤其是dependency:analyze
目标:
The Maven Dependency Plugin will help, especially the dependency:analyze
goal:
dependency:analyze
分析此项目的依赖关系,并确定使用和声明的依赖项;使用和未声明的;未使用并声明.
dependency:analyze
analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.
可能需要进行清理的另一件事是依赖项收敛报告来自 Maven项目信息报告插件.
Another thing that might help to do some cleanup is the Dependency Convergence report from the Maven Project Info Reports Plugin.
这篇关于有没有一种简单的方法可以从maven pom.xml中删除未使用的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!