有没有一种简单的方法可以从 maven pom.xml 中删除未使用的依赖项? [英] Is there a simple way to remove unused dependencies from a maven pom.xml?

查看:16
本文介绍了有没有一种简单的方法可以从 maven pom.xml 中删除未使用的依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多模块和许多 pom.xml 文件的大型 Maven 项目.该项目已更改,我怀疑 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 Plugin 会有所帮助,尤其是 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆