为什么我需要在mavenpom.xml文件中没有包含的jar文件中寻找class?

Why do I need to look for a class in a jar file that is not included in the maven pom.xml file?

我已经在 nexus 中导入了一个 jar 文件,一个本地 maven 存储库,并通过 java 构建路径在引用的库中导入了另一个 jar 文件。

问题似乎是完全引用了Eclipse项目的pom文件中引用的jar文件中的class,而没有使用引用lib中的classes

两个 jar 文件中存在相同的 class。

我不知道是什么原因造成的。

这是 eclipse 错误?

例如:

a.jar, b.jar -> 都有 ReferenceClass(相同的包)

一个项目的pom.xml -> 依赖a.jar

MyProject 的引用库 -> 依赖关系 b.jar

my project:MyClass.java -> import ReferenceClass -> reference a.jar

build path

project structure

pom.xml

不要在 Maven 项目中使用 "Referenced Libraries"。这会使 Eclipse 感到困惑。

此外,尽量避免在 class 路径中出现两次相同的 class。