Cannot resolve symbol XYZ in IntelliJ although maven builds sources properly

Today I stumbled upon a weird problem with IntelliJ IDE.

I had to update one of maven dependencies version, which introduced a new class I wanted to use.
It was possible to build the project without any problem by mvn install, but still the editor marked it red with message ‘cannot resolve symbol’.
Consequently it was for instance impossible to run single unit tests from IDE, because IntelliJ considered this code as invalid to compile.

I tried invalidating caches, reloading pom.xml etc. but to no avail.

Finally it turned out that for some reason IntelliJ is incapable to track changes in maven artifacts versions, if the version is given in a variable like :

<dependency>
      <groupId>com.jetdrone</groupId>
      <artifactId>yoke</artifactId>
      <version>${yoke.version}</version>
    </dependency>

The workaround goes as follows :

1. Replace ${yoke.version} with raw string version
2. Go to File -> Settings … -> (search) maven -> repositories and click ‘Update’ on your local maven repository.
3. Invalidate caches. (File -> Invalidate caches / restart … )
4. Now it should work
5. You can replace tag content with variable reference again

I wasted quite a lot of time for that, so maybe it will help someone with similar issue 😉

One Comment

  • Hi I followed your steps but still I face the same problem on my system.