Intellij MavenWrapperDownloader.java: Can not resolve symbol error

Viewed 720

Setup:

  • Intellij IDEA community edition 2020.2
  • Spring Bott starter parent: 2.3.5
  • Java 11
  • WRAPPER_VERSION: 0.5.6
  • mvn 2

Hi, I googled a lot e.g. here but I just can't fix it. I created a new mvn spring project with Intellij. When I commit the project I get errors detected by code analyses in class: MavenWrapperDownloader.java. e.g. It reports:

Cannot resolve symbol String

I tried:

  1. invalidate caches and restart
  2. delete .idea folder and reimport
  3. checked sdk setup
  4. mvn reimport
  5. mvn clean and then rebuild (while the build is always successful)

I'm pretty new to maven. I guess the scope of the mvn package might be wrong because the build process works as expected.

UPDATE: I reinstallt my openjdk11. No success. Then I found out that my .mvn/wrapper dir is not set as source root. I know that was never the case in my other projects. As a trial I've set my .mvn folder as source root and now the MavenWrapperDownloader.java file is recognized as a java class and the compiler interprets the symbols. But now there is another error. It says I have to define a package name for that class because the class does not have one per default. It is pretty strange to me. I also tried to use another spring boot starter version but nothing changed

When I execute Analyze->inspect code I get the following:

enter image description here

2 Answers

I had the same problem and File -> Invalidate Caches/Restart fixed it - at least for now.

IntelliJ Ultimate 2020.3 Spring Boot Starter Parent 2.4.2 Java 15 Maven 4.0.0 Maven Wrapper 0.5.6

The easiest solution is to generate your project again with Spring Starter.

After you set up everything you need at pom file -> Generate -> Download it.

Open with your IDE and copy-paste all code sources which you have already written.

Related