Maven依赖冲突仅在eclipse中 [英] maven dependency conflict only in eclipse

查看:87
本文介绍了Maven依赖冲突仅在eclipse中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有多个模块的多个应用程序;我们一直在使用NetBeans.我正在尝试将开发移到日食之上.

We have several applications as a number of modules; we've been using NetBeans. I am attempting to move the development to eclipse.

所有项目都是使用Maven构建的.其中之一使用dbunit,也使用POI.当我尝试在eclipse中编译它时,它给我一个错误的方法签名错误.使用Maven构建的NetBeans和使用命令行构建的NetBeans都没有给我这个错误.

All projects are built with Maven. One of them uses dbunit, and also POI. When I try to compile it in eclipse, it gives me an error for a bad method signature. Neither NetBeans build with maven nor command-line build give me this error.

我发现编译器正在尝试使用比我们使用的POI老的POI版本进行编译.根据dbunit的maven存储库信息,在编译范围内将POI的特定版本指定为dbunit的依赖项.我不明白为什么这会把那个版本的POI拖入我的编译器中,因为我使用的是dbunit,而不是对其进行编译.

I discovered that the compiler was attempting to compile using a version of POI older than the one we use. The specific version of POI is designated in compile scope as a dependency for dbunit, according to dbunit's maven repository info. I don't understand why that would pull that version of POI into my compile, since I'm using dbunit, not compiling it.

我也不明白为什么它会为日食而不是为其他两个编译操作中的任何一个而被拉入.

Nor do I understand why it gets pulled in for eclipse and not for either of the other two compilation operations.

我在SO和eclipse bug报告站点上看到了很多关于eclipse如何仅使用一个类路径的评论,并且很难更改并且没有更改计划.

I have seen a number of comments on SO and on the eclipse bug report site about how eclipse uses one classpath only, and that it would be difficult to change and that there are no plans to change.

如果是这样,其他人如何处理呢?我无法在世界上(甚至在我所在的城市)拥有唯一的项目,而该项目使用的库具有与项目编译冲突的编译依赖项.是否有m2e补丁程序或Eclipse解决方案,希望它不涉及修改全部20个pom.xml文件?

If that's true, how are other people dealing with this? I can't have the only project in the world (or even in my city) that uses libraries that have compile dependencies that conflict with the project compilation. Is there an m2e patch, or an eclipse workaround, hopefully something that does not involve modifying all 20 pom.xml files?

推荐答案

编译依赖项是可传递的.Maven2Eclipse插件仅使用树中一个库的依赖项(可能与Maven不同).

Compile dependencies are transitive. The Maven2Eclipse plugin uses only one dependency from the tree for a library (probably not the same as Maven does).

为了安全起见,使用dbunit时应排除POI:

To be on the safe side, exclude POI when using dbunit:

<dependency>
  <groupId>org.dbunit</groupId>
  <artifactId>dbunit</artifactId>
  <version>...</version>
  <exclusions>
    <exclusion>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
    </exclusion>
  </exclusions>
</dependency>

如果使用新版本的dbunit(如2.4.3),则对POI的依赖关系是可选的,这意味着不可传递.

If you use a newer version of dbunit like 2.4.3, the dependency to POI is optional, meaning not transitive.

这篇关于Maven依赖冲突仅在eclipse中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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