1

I'm trying to import dependencies in Maven via Idea Intellij, however I get a Dependency [version] not found error:

enter image description here

It happens for all dependencies in pom.xml.

I checked the local repository /home/<User_Name>/.m2 folder and the jars are there:

enter image description here

enter image description here

enter image description here

So the jars exist, but Idea doesn't see them. I do reload Idea's Maven by clicking the left round button:

enter image description here

It worked fine on Windows, but doesn't on Ubuntu 18.04.

parsecer
  • 4,758
  • 13
  • 71
  • 140
  • See https://stackoverflow.com/a/42427510/104891. You need to check the logs. – CrazyCoder Apr 12 '20 at 18:32
  • Does a `mvn clean install` work outside of IntelliJ (directly using the command line) ? Just trying to understand if the jars can be read by the terminal. – Shrinath Apr 12 '20 at 18:34
  • Yes, it works fine - `BUILD SUCCESS`. Also, I can use the dependency libraries in my code - the imports work fine. The only issue is that the versions are red in `pom.xml` but it doesn't seem to affect anything. – parsecer Apr 12 '20 at 18:45

1 Answers1

1

Try going to IntelliJ IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing and mark the options like in the image below:

enter image description here

Alcastic
  • 374
  • 5
  • 15
  • have you checked IntelliJ is using the right .m2 repository that you have configured? (you can check it in: IntelliJ IDEA -> Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Local Repository) – Alcastic Apr 12 '20 at 21:21
  • Yes, it's in `/home/username/.m2/repository`, but the Override checkboxes are not checked. Should they be? – parsecer Apr 12 '20 at 21:29
  • If paths are okay, then you don't need to override them. Other thing you can try is to force recreation of the configuration of your project: 1) close all IntelliJ windows 2) Go to you project folder and delete .idea/ directory and *.iml files 3) Open again your project with IntelliJ and if a popup appears asking you to 'Enable Auto import' then you have to confirm the operation. – Alcastic Apr 12 '20 at 21:44
  • No, still no luck. Somehow one dependency - `okhttp` isn't highlighted in red, while the other two - `gson` and `hibernate-core` are. Very weird behaviour. – parsecer Apr 14 '20 at 20:37