IntelliJ IDEA:如何在pom.xml中将项目库与依赖项同步? [英] IntelliJ IDEA: How to synchronize project libraries with dependencies in pom.xml?

查看:1152
本文介绍了IntelliJ IDEA:如何在pom.xml中将项目库与依赖项同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的项目的一个pom.xml(有几个模块)中更改依赖项版本时,我看到了新版本以及项目结构的库部分中的旧版本。

When I change a dependency version in one of the pom.xml of my project (which has several modules) I see the new version and also the old one in the Libraries section of the Project Structure.

例如,最近我将Drools从版本5.4更改为5.5。当我进入Libraries部分时,我看到了两个库,所以我手动删除了5.4。

For example, recently I changed Drools from version 5.4 to 5.5. When I entered the Libraries section I saw both libraries so I manually removed the 5.4.

如何告诉IDEA删除pom.xml文件中未引用的库?

How can I tell IDEA to remove libraries that are not referenced in the pom.xml files?

谢谢

推荐答案

嗯,这不是问题同步项目库。

Well, this is not problem with synchronize project libraries.

可以通过设置>设置同步设置。 Maven>导入>自动导入maven项目

但我认为这是其他问题。它是由使用不同Drools版本的其他依赖引起的。您必须明确地从该依赖项中排除旧的Drools版本。

But I think this is other problem. It is caused by other dependency which uses different Drools version. You have to exclude the old Drools version from that dependency explicitly.

如何找到导致依赖的问题?

How to find this problem causing dependency?

打开依赖关系树。可以通过maven模块上的右键单击来完成,然后单击显示依赖项或按Ctrl + Alt + Shift + U 。

Open your dependency tree. It can be done via right click on your maven module and click Show dependencies or hit Ctrl + Alt + Shift + U.

会有一些红线导致同一个maven工件的不同版本。只需单击它,Idea就会引导您发生不一致的地方。然后右键单击错误版本的maven工件,然后单击 Exlude 或Shift + delete。

There will be some red lines leading to different version of the same maven artifact. Just click on it and Idea will lead you where the inconsistency happened. Then just right click on maven artifact with wrong version and click Exlude or Shift + delete.

检查的pom.xml 。你应该找到这样的一行:

Check your pom.xml. You should find line like this:

<exclusions>
   <exclusion>
      <artifactId>drools</artifactId>
      <groupId>drools</groupId>
      <version>5.4</version>
    </exclusion>
</exclusions>

这篇关于IntelliJ IDEA:如何在pom.xml中将项目库与依赖项同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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