Maven加载错误版本的依赖项 [英] Maven loads wrong version of dependency

查看:381
本文介绍了Maven加载错误版本的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的maven pom.xml中,我具有以下依赖性:

In my maven pom.xml I have the following dependency:

<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>Chart.js</artifactId>
    <version>2.0.2</version>
</dependency>

在构建它时,maven会加载版本1.1.1而不是2.0.2.我无法解释为什么会发生这种情况. mvn dependency:tree给我以下输出:

When I build it, maven loads Version 1.1.1 instead of 2.0.2. I can't explain why this could happen. mvn dependency:tree gives me the following output:

[INFO] my.group:mypackage:war:0.0.1-SNAPSHOT
[INFO] ...
[INFO] +- org.webjars.bower:Chart.js:jar:1.1.1:compile
[INFO] +- org.webjars.bower:angular-chart.js:jar:0.10.2:compile
[INFO] ...

因此,Chart.js是我项目的直接依赖项,没有其他依赖项依赖于Chart.js并强制加载版本1.1.1.即使我查看IntelliJ中的有效pom,也没有对版本1.1.1的依赖,只有我对2.0.2的依赖.

So, Chart.js is a direct dependency of my project and no other dependency depends on Chart.js and forces loading of version 1.1.1. Even when I look at the effective pom in IntelliJ, there is no dependency for version 1.1.1, only my dependency for 2.0.2.

知道为什么Maven加载了错误的版本吗?

Any idea why maven loads the wrong version?

推荐答案

您的问题是angular-chart.js:jar:0.10.2与chart.js 1.1.1有依赖关系.您在这里有冲突.

Your problem is that angular-chart.js:jar:0.10.2 has a dependency to chart.js 1.1.1. You have a conflict here.

查看此链接以查看所有依赖项: https://maven-repository.com/artifact/org.webjars.bower/angular-chart.js/0.10.2

Look at this link to see all dependencies: https://maven-repository.com/artifact/org.webjars.bower/angular-chart.js/0.10.2

添加angular-chart.js依赖项时,您需要添加排除标签:

You need to add exclusion tags when you add the angular-chart.js dependency:

<dependency>
  <groupId>org.webjars.bower</groupId>
  <artifactId>angular-chart.js</artifactId>
  <version>0.10.2</version>
  <exclusions>
      <exclusion> 
          <groupId>org.webjars.bower</groupId>
          <artifactId>Chart.js</artifactId>
      </exclusion>
  </exclusions>
</dependency>
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>Chart.js</artifactId>
    <version>2.0.2</version>
</dependency>

这篇关于Maven加载错误版本的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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