简体   繁体   English

Eclipse依赖关系不在pom.xml中,但仍在“ Maven Dependencies”组下

[英]Eclipse Dependency is not in pom.xml but still under “Maven Dependencies” group

I added a dependency using Maven to my Java project in Eclipse. 我使用Maven将依赖项添加到Eclipse中的Java项目中。 I added one version of the dependency from repository, then I saw that version is not what I want, then added an higher version (that doesn't exist in repositories) manually using maven's commands. 我从存储库添加了一个版本的依赖关系,然后看到该版本不是我想要的版本,然后使用maven的命令手动添加了更高版本(存储库中不存在)。 And finally I deleted the older version from pom.xml, and added the new version to there. 最后,我从pom.xml中删除了较旧的版本,并在其中添加了新版本。 I used following command to add newer version to repo: 我使用以下命令将新版本添加到仓库中:

mvn install:install-file -Dfile=PATH_OF_JAR -DgroupId=GROUP_ID -DartifactId=ARTIFACT_ID -Dversion=VERSION -Dpackaging=jar

Now the problem is that older version remains in "Maven Dependencies" group. 现在的问题是,旧版本仍保留在“ Maven Dependencies”组中。 And my code part using that dependency jar won't see the new version. 使用该依赖项jar的代码部分将看不到新版本。 I deleted manually the older version from Maven local repo, and also executed the "purge" command of Maven. 我从Maven本地存储库中手动删除了旧版本,并执行了Maven的“清除”命令。 Every time I update, the older version keeps coming back. 每次更新时,旧版本都会不断返回。 How do I make my project just see the newer version and completely get rid of the older version? 我如何使我的项目只看到较新的版本,而完全摆脱较旧的版本?

The pom.xml entry is as following (which points the new version, the version I desire): pom.xml条目如下所示(指向新版本,即我想要的版本):

<dependency>
        <groupId>org.eclipse.jface</groupId>
        <artifactId>org.eclipse.jface</artifactId>
        <version>3.7.0</version>
    </dependency>

Sounds like another dependency is bringing it in... Do a maven dependency tree to resolve your conflicts. 听起来像是另一个依赖项正在引入它...做一个maven依赖项树来解决您的冲突。 See apache's guide here 在这里查看apache的指南

mvn dependency:tree -Dverbose -Dincludes=YOUR_OLD_DEPENDENCY

You may also use tools to aid this such as your IDE 您也可以使用诸如IDE之类的工具来帮助实现这一目标。

Intelli-j 智能

  • right click > Maven --> Show Dependency 右键单击> Maven->显示依赖关系
  • shortcut : ctrl + alt + shift + u 快捷键:Ctrl + Alt + Shift + U

Eclipse 日食

  • click on the pom's "dependency hierarchy" tab suggested by @FrVaBe bellow 单击@FrVaBe所建议的pom的“依赖关系层次结构”选项卡

If you use eclipse than have a look at the "Dependency Hierarchy" tab of the pom.xml viewer. 如果您使用eclipse,则请查看pom.xml查看器的“ Dependency Hierarchy”选项卡。 Click at the org.eclipse.jface artifact on the resolved dependencies tab and see where it comes from (maybe your version is overruled by a transitive dependency). 单击已解决的依赖项选项卡上的org.eclipse.jface工件,然后查看它的来源(也许您的版本被传递的依赖项所取代)。

This answer is quite similar to @MMans answer (+1 for this) - just using other tools that might be easier to use than the command line (for some) ;-) 这个答案与@MMans答案非常相似(为此+1)-仅使用其他可能比命令行更容易使用的工具(对于某些工具而言;-)

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

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