Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij maven imports have broken classpath

I'm using Intellij 13, I've been using Maven quite happily for awhile now to manage the JAR dependencies.

But the last few I've imported are causing a broken classpath issue, and they're not being installed to the repository.

I though it might be just the JSONPath library, but when I tried to install Selenium drivers it also happened with those libs. I checked the local repository and the directories exist, but the JARs haven't downloaded.

This only started happening recently, and a lot of other dependencies have been installed fine (but not since this issue started happening). I'm really not sure what might have caused it.

Does anyone know how to troubleshoot this? Or why the JARs aren't installing? And can I just trigger an update somehow from Intellij to try to reinstall them?

enter image description here

Quick Edit Here:

I tried installing the modules using Intellij's "add library" feature. It installed them fine, whereas before I was just updating them directly in the pom.xml and it was downloading them.

The library feature seems a little better because it automatically adds them to my output artefacts anyway, but it would be nice if it also updated the pom so I can use it outside of the intellij environment.

So I'm not sure why updating the pom.xml isn't working any more...

like image 493
Richard G Avatar asked Sep 11 '15 05:09

Richard G


People also ask

Are Maven dependencies added to classpath?

Maven does set the classpath to the dependencies correctly, but not prefixed with repository location. It will look like this in your Manifest file. It is upto you to place the dependant jars in the same folder as the jar which you are running.

Why is IntelliJ not importing Maven dependencies?

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.


2 Answers

I've had this issue in IntelliJ IDEA 2017 Ultimate.

After changing dependency versions, the IDE was unable to fix the path on its own. I went to my ~/.m2 directory and deleted all of the dependencies for the problem jar and then executed the "ReImport All Maven Projects" action. When it was complete, the dependency issue was resolved.

like image 138
th3morg Avatar answered Sep 24 '22 21:09

th3morg


I had this problem with the Community version of IntelliJ Community edition. I was able to solve the problem using this process:

  1. Click "Help" menu
  2. Click "Find Action" and type "Maven Settings."
  3. Click "Maven Settings."
  4. Click the arrow next to "Maven" on the left hand side, to see the submenu
  5. Click "Importing"
  6. Check "Import Maven Projects automatically" and click "OK."

Partial screen shot of "Maven Settings" screen

This should pull in all of the Maven dependencies from the pom.xml file, without you needing to manually add the libraries.

I hope this helps.

like image 33
Christian Gibbs Avatar answered Sep 24 '22 21:09

Christian Gibbs