I have a JDK 1.7 project with a maven dependency to a local jar in my maven repo.
I'm unable to build the project using Intellij, with the errors that a symbol cannot be found (the symbol is a class importing packages from the local jar)
But I can successfully build the project using 'mvn package'.
I've spent so much time looking for solutions, things I've already done:
- Invalidated cache
- 'mvn clean install' the local jar dependecy
- Marked to 'autoload snapshots' in Intellij's maven configuration
- Reimpoted maven in Intellij
- Syncornized
This error happend to my couple of times before, but usually just closing the Intellij and /or doing the 'mvn clean install' did the trick.
Please help.
I've found out that my .iml file and pom were conflicting and causing the issue.
IDE uses its own bundled copy of Maven when doing builds. If maven on terminal is different from IDE, then you want them to be the same.
GOTO (On a Mac)- IntelliJ Idea -> Preferences -> Build,Execution,Deployment -> Build Tools -> Maven. Set the path for your Maven Home Directory To find the path for Maven which you use from terminal, type command
mvn -version
and that should print out bunch of details including the dir path. Put that in Maven Home Directory.To be safe you can also do the same for JDK location
==== Some Other Things that can cause such issues ===
If doing mvn package or mvn clean install builds, then it has to do something with IDE caches. Among other things, this one usually helps with such errors -->
File -> Invalidate Caches
Many valuable tips in the other answers here, just want to add the solution that worked for my problem.
We recently started using a private Maven repository and always do
mvn -s settings.xml
when invoking the Maven cmdline. IntelliJ does of course not know about the private repo, so it needs a little help.Go to Settings -> Build, Execution, Deployment -> Build tools -> Maven and override the "User Settings file" option.
I tried invalidating cache, changing the Maven to installed version and nothing worked.
Closing and recreating a new project resolved it.
Maven ReImport worked for me like below...
In my case my iml was not in sync, so I deleted the iml for the specific module and then under maven option select unignore project to recreate iml