IntelliJ not able to resolve classes of external Libraries for Maven projects

已回答

I imported a maven project and IntelliJ was able to load all the dependencies. Project is building fine. Issue is in all my files all the classes that have been used from the libraries are shown as red. As an issue I don't get the auto suggestions which is causing me lot of issues.

 

Imports shown as unused and BindingAwareProvider, LoggerFactory, Logger shown as symbols not resolved as below:

However, when I click on the api from the imports, I am able to see that jar in the external Libraries with BindingAwareBroker class as below:

External Libraries having the jars, 1 example shown below:

IntelliJ version: 15.0.2 Maven version in IDE: 3.3.3 Java: 1.7

We have a local repo from where the dependencies are getting fetched.

Can someone suggest what is wrong here? Why is the whole project messed up with red symbols. :( :(

4
Avatar
Permanently deleted user

Deleting .idea, iml and restarting project helped in my case also

0
Avatar
Permanently deleted user

Hi Serge Baranov,

 

I am also facing the same issue with Intellj Idea Ultimate edition - 2017-2.2 version.

 

And also raised the request(#1848651), could you please check and let me know ASAP.

 

Thank you!

//Sai Chaitanya

0

Hello Sai,

I'm checking your request.

0
Avatar
Permanently deleted user

Hi Yaroslav,
I was able to resolve the issue. The problem is with pom.xml regarding spring-boot-maven-plugin where I have added the execution goals then it resolved.

Thanks!

 

 

0
Avatar
Permanently deleted user

I faced a similar issue. I could resolve it by moving/copying the settings.xml file from $MVN_HOME/conf to ~/.m2 folder. As MVN_HOME was not detected by Idea it could not resolve the settings.xml from MVN_HOME. 

0
Avatar
Permanently deleted user

For me the problem was that the project I had imported did not inherit from spring-boot-dependencies but rather spring-boot-starter.  this caused the project i was importing to be structured like an application and not a library and so its classes would not be jar-ed at the head of the project.  if they are not at the head of the project then IntelliJ can see them, but they aren't really in your classpath for import.

0

I had the same problem, but in my case it was due to some generated code. IntelliJ saw a pom in the project where java is generated from XSDs, and it imported it as a module dependency rather than importing the jar with the same name in my m2 directory. The solution for me (don't know if it will stick yet) was to remove the module from the project structure, then manually add the library. It looks to be stable after a subsequent maven update.

0

For me, the problem was that I had some remote repositories configured in my maven settings (~/.m2/settings.xml), and somehow they had some problems.

Removing the settings.xml file forced IntelliJ to only fetch the artifacts from my local repository and everything worked.

0
Avatar
Permanently deleted user

I had the exact same issue. Nothing mentioned anywhere worked. Then I checked the filetypes. Go to preferences--> EDitor--> File Types---> java Class

Check if it has *.class added in it, If not please add it. It will get resolved

0

I have the same problem but nothing mentioned already helped me, I have already raised #2655239

0
Avatar
Permanently deleted user

I solved this by setting the Project Structure > Project Settings > Modules > Dependencies > Module SDK to the correct one. In my case it was not set, but I would assume there could be other times you have multiple Java SDKs and you will need to match the to the one which is being used by the Maven import.

 

This was causing the classpath errors:


This resolved the classpath errors:

0

I am facing a similiar issue but I am unable to resolve it from last 2 days. I have also created a ticket https://youtrack.jetbrains.com/issue/IDEA-273279.

 

Can someone please check this and help me?

0

For me it worked deleting .idea folder and .iml files, then re-importing the project.

0

请先登录再写评论。