简体   繁体   English

Maven依赖项和非Maven依赖项冲突

[英]Maven dependency and non-maven dependency conflict

I have a project that has some dependencies. 我有一个依赖项的项目。 Some of those dependencies are Mavenized and some of them aren't. 这些依赖关系中有一些是Mavenized,有些则不是。

Two dependencies use the same class, but from different packages, one from Java Libs and the other one from GWT libs. 两个依赖项使用相同的类,但使用不同的包,一个依赖项来自Java Libs,另一个依赖项来自GWT库。 This makes the app crash. 这会使应用程序崩溃。

MyPackage Depends On: Package A MyPacakge Depends On: Package B MyPackage依赖于:程序包A MyPacakge依赖于:程序包B

Package B and Package A are conflicting. 程序包B和程序包A发生冲突。

Currently the only solution I've found was to exclude one the conflicted dependencies. 目前,我找到的唯一解决方案是排除一个相互冲突的依赖项。

Is there any plugin for Eclipse-Maven or any workaround to easily solve this?. 是否有用于Eclipse-Maven的任何插件或任何可轻松解决此问题的解决方法?

Thanks. 谢谢。

In my opinion,2 or more classes with the same package path and same class name mixed in the class path,the first class loaded will come into use,and the later ones are all ignored.And no exception or even currution will happen. 我认为,在类路径中混合了两个或两个以上具有相同程序包路径和相同类名称的类,将使用第一个加载的类,而后一个将被忽略。并且不会发生异常甚至无效。 This jvm class loading rule is frequently used in enterprise app to fix bugs quickly.Make a jar named with name of 'a_name_yyyyMMddHHmmss.jar' to replace the mis-coded java class with out compiling the whole projects and upgrading. 这个jvm类加载规则经常在企业应用程序中用于快速修复错误。制作一个名为“ a_name_yyyyMMddHHmmss.jar”的jar来替换编码错误的Java类,而无需编译整个项目并进行升级。 Would you please add your exception log or something? 您能否添加例外日志或其他内容?

I have several advise: 我有几点建议:

  1. Make sure the GWT version and jdk version the 'same'/compatible. 确保GWT版本和jdk版本为“相同” /兼容。
  2. Use the "Dependency Exclusions" of maven pom config.Refer here . 使用maven pom config的“依赖项排除”。请参阅此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM