Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA: How to synchronize project libraries with dependencies in 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.

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.

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

Thank you

like image 737
Ferran Maylinch Avatar asked Oct 18 '13 07:10

Ferran Maylinch


People also ask

Why Maven dependencies are not showing in IntelliJ?

If the dependencies weren't imported correctly (IntelliJ IDEA highlights them), try to perform the following actions: You can check your local maven repository in the Maven | Repositories settings and try to update it. You can check the jar file of the local . m2 repository to see if it was downloaded correctly.


1 Answers

Well, this is not problem with synchronize project libraries.

The synchronization settings can be set via Settings > Maven > Importing > Import maven project automatically

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?

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.

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.

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

<exclusions>
   <exclusion>
      <artifactId>drools</artifactId>
      <groupId>drools</groupId>
      <version>5.4</version>
    </exclusion>
</exclusions>
like image 161
Milan Baran Avatar answered Oct 12 '22 12:10

Milan Baran