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.
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. :( :(
请先登录再写评论。
Please try File | Invalidate Caches | Invalidate and Restart.
This I have already tried. No Luck.
Please submit a ticket to support with idea.log (https://intellij-support.jetbrains.com/hc/articles/207241085) and a sample project to reproduce the problem.
Thanks Serge. The code is copyrighted, I am not sure what to provide now. Also, whether it's problem with the idea, or there is some problem on my side, don't know.
It will be nice if you just provide me with the following info:
1. If we have already existing maven project, what is the best way to import the same. Any steps documented, I have seen a lot on the internet and somehow tried all the options.
2. We have a local repo in which all the jars are placed. Can that cause some issue? Is any data other than the jars is required?
3. If I see the Jars in the external dependencies, can we say that they are added to the classpath. I am asking because all the classes and Interfaces shown as not imported are giving the following option to resolve the errors:
1. Open the root pom.xml or import from the root pom.xml (import allows to specify more options, open uses default options).
2. It should not be a problem, the jars are enough.
3. External dependencies shows everything, it could be that the dependency is added to some other module and the module that has the problem doesn't have this specific dependency for some reason.
Please try to delete .idea directory and .iml files, then reimport the project from Maven.
Just a add on question for point 3:
Can I consider adding the required libraries for the particular module as dependencies? As a workaround.
I tried this for 1 module, but again, hard luck.
Checked with delete .idea directory and .iml files, then reimport the project from Maven. Hard Luck
Dependencies in a Maven project should be configured inside pom.xml instead of manually adding them in the module settings. All the changes you make there will be reverted on the next Maven project refresh/import.
Oh...This makes sense now. So the issue is that my project pom is having the dependencies, but when I go to the Open module dependencies -> Dependencies, it does not show those dependencies loaded.
Please, I have the same issue or last 72 hours I'm on 2016.3.1, pom.xml has the dependency, but module "Dependencies" tab doesn't see it, also not in .iml file also. Help!!!!! Is this a bug?
Is it possible to reproduce the issue with new sample project?
@Ming2198 please submit a ticket to support with idea.log attached (https://intellij-support.jetbrains.com/hc/articles/207241085).
Any update on this? I also have the same issue.
File a ticket to support, Maven issues are not the same, need the logs and other details to find out.
I have similar problem, however adding the jar to Classpath seems to help.
Project Structure > Platform Settings > SDKs > Classpath
Click the + and add the jar
Let me know if that was helpful
It's not the correct way of managing the dependencies when using Maven, only a hacky workaround. Please contact support for help: https://intellij-support.jetbrains.com/hc/requests/new.
I had such an Issue with multi module projects, finally I solved the problem during the time I imported the new project.
and
That worked for me... but you might as well have another problem :)
Right click on project->Maven->Reimport resolved the problem
Hi, I have the same problem a long time. I have tried different ways to solve it but without success, for example
Nothing works for me.
Here is appropriate stackoverflow topic. The interesting point is that the api.iml file contains the following XML for all required dependencies, but IDEA doesn't see them.
Is this topic alive still? Or I need to create another one?
Submit a new question or contact support: https://intellij-support.jetbrains.com/hc/requests/new.
@Serge Baranov, done
remove the .idea project and restart the multi-module project in IDEA work for me!
IntelliJ IDEA 2016.3
Hi Serge,
I was too facing this same issue on Intelli14 however by following your steps, I was able to resolve this issue:-
"Please try to delete .idea directory and .iml files, then reimport the project from Maven...."
Thanks,
Cheers!
Created an account just to say that deleting the .idea directory and re-importing worked for me. Thanks for the tips.
Deleting the .idea directory and re-importing worked for me also.
Deleting the .idea directory, Restarting the project, Ticking search for projects recursively when importing module Worked for me.
Deleting the .idea directory and .iml files worked for me also.
@Sahil Shah similar annoying problem, my issue is that i select the modules suggested by idea when i import a project,those suggested modules are like below:

with unselecting ,everything is so harmonious,no more red annoying stupid resolving problems!
hope this will help you
None of the above solutions worked for me. When I tried importing the maven module, I noticed it said "project is ignored", and I could not click the check box to import the module:
I went to Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Ignored Files, and unchecked the module that was being ignored:
After this, I was given the "Import Class" option after doing the "Add Maven Dependency..." step.