Cannot resolve symbol in IntelliJ

Updated:

If you open a Java project for the first time in IntelliJ, and you’re greeted with a bunch of unresolved classes and keywords, highlighted in red like this (yuck!):

Red highlighted keywords in IntelliJ

It might be because IntelliJ hasn’t correctly recognised the project as a Maven project.

To confirm this, have a look at the pom.xml file icon. If it’s just shown as a normal XML icon like this:

pom.xml with XML icon

Then you’ll need to specifically tell IntelliJ to read the file as a Maven project, by right-clicking the pom.xml file and choosing this option:

Add as Maven Project in IntelliJ

Now IntelliJ should show your pom.xml with a proper Maven icon:

pom.xml with Maven icon in IntelliJ

And then… Maven will go do stuff and resolve dependencies.

Now is a good time to get a cup of coffee. ;-)

Leave a Comment