如何匹配Maven groudId发行版本

时间:2017-10-05 13:55:26

标签: java spring maven

我有一个maven项目,我刚刚更改了spring-data-neo4j依赖项版本。

它有:

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-commons</artifactId>
        <version>1.12.0.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>5.0.0.RELEASE</version>
    </dependency>

之前是

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>4.1.3.RELEASE</version>
    </dependency>

所以,我收到一个错误:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) on project myproject: An exception occurred while running. null: InvocationTargetException: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; -> [Help 1]

这是因为(我认为)我的2个依赖项具有相同的groupId但不能从同一版本的组中提取。

问题

如何知道我应该使用哪个spring-data-commons版本来匹配spring-data-neo4j的5.0.0版本?

更新

我通过尝试大量版本来修复我的问题,直到错误消失。这不是一个真正的答案,但我的问题现在已经消失了。

1 个答案:

答案 0 :(得分:1)

问题在于将spring-data-commons 1.12.0.RELEASE单独定义为pom.xml中的依赖项

只定义spring-data-neo4j 5.0.0.RELEASE会传递给你的是spring-data-commons的归属版本,即2.0.0.RELEASE,但如果你还单独定义了较旧的spring-data-commons 1.12 .0.RELEASE,然后它将覆盖较新的传递依赖版本,并将导致经验丰富的问题​​;可能是因为较新版本的neo4j会尝试使用在版本1.12.0.RELEASE和2.0.0.RELEASE之间发生变化的spring-data-commons API

请参阅mvn dependency:tree打印输出

的相关部分

仅定义spring-data-neo4j 5.0.0.RELEASE

[INFO] +- org.springframework.data:spring-data-neo4j:jar:5.0.0.RELEASE:compile
[INFO]    +- org.springframework.data:spring-data-commons:jar:2.0.0.RELEASE:compile

定义spring-data-neo4j 5.0.0.RELEASE以及spring-data-commons 1.12.0.RELEASE

[INFO] +- org.springframework.data:spring-data-commons:jar:1.12.0.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-neo4j:jar:5.0.0.RELEASE:compile
          (...no transitive spring-data-commons:jar here)