且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Eclipse在启动配置中使用错误的maven依赖项

更新时间:2021-08-20 01:50:16

注意此答案是与OP讨论的摘要

看起来像 vertex-hazelcast 声明两个编译并测试 hazelcast 的范围依赖性。这些范围不是传递性的,所以我的理解是这个版本将被设计包含在类路径中。 @Echnalb建议使用排除是推荐解决方法。

It looks like vertex-hazelcast declares both compile and test scoped dependencies on hazelcast. These scopes are not transitive so it's my understanding that this version will be included in the classpath by design. @Echnalb suggestion to use an exclusion is the recommended way to resolve this.

由于这种情况没有奏效,它可能是一个祖先也宣布了一个也需要排除的依赖。

As that hasn't worked, it could be an ancestor is also declaring a dependency which would also need to be excluded.

在查看了在 vertex-hazelcast 中声明的其他依赖项之后,我检查了 hazelcast-client 看看它是否也声明了对早期版本的 hazelcast 的依赖,假设祖先依赖被添加到类路径中,尽管被排除在父类之外。

After looking through some other dependencies that were declared in vertex-hazelcast, I checked hazelcast-client to see if it also declared a dependency on the earlier version of hazelcast the assumption being that the ancestral dependency was being added to the classpath despite the exclusion from the parent.

包括这样的依赖:

<dependency>
    <groupId>com.hazelcast</groupId>
    <artifactId>hazelcast</artifactId>
    <scope>test</scope>
    <version>${project.parent.version}</version>
    <classifier>tests</classifier>
</dependency>

我建议( ed )为 hazelcast-client 这似乎解决了这个问题。

I suggest(ed) adding an exclusion for hazelcast-client which seems to have solved the problem.

@Guss评论


  • 在排除之前,运行依赖:树,hazelcast-client是
    根本没有列出

  • 有趣的是,依赖:tree 没有检测到测试范围的依赖关系。有没有办法强制它切换范围?

  • Prior to the exclusion, running dependency:tree, hazelcast-client is not listed at all
  • It is interesting that dependency:tree does not detect test scoped dependencies. Is there's a way to force it to switch scopes?