如何在类路径中检测重复的JAR? [英] How to detect duplicate JARs in the classpath?
问题描述
有没有人有代码来检测类路径中的重复JAR?
Does anyone have code to detect duplicate JARs in the classpath?
背景:当类路径中有两个版本的同一个JAR时,真的会发生奇怪的事情。使用Maven等工具时甚至会发生这种情况:更改依赖关系并构建WAR而不先清理。由于未清理 target / webapp / WEB-INF / lib
,因此依赖关系将在那里两次。
Background: When there are two versions of the same JAR in the classpath, really strange things can happen. This can even happen when using tools like Maven: Change a dependency and build the WAR without cleaning first. Since target/webapp/WEB-INF/lib
wasn't cleaned, the dependency will be in there twice.
这有安全网吗?
推荐答案
JBoss Tattletale 可能会对此有所帮助。
JBoss Tattletale might help you with this.
这是一个免费的工具,可以扫描项目使用的JAR文件并给出关于他们的报告。
It's a free tool which scans the JAR files used by your project and gives you a report about them.
其功能包括:
- Spot if if一个类位于多个JAR文件中
- 如果相同的JAR文件位于多个位置,则为Spot
- 查找具有不同版本号的类似JAR文件
这篇关于如何在类路径中检测重复的JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!