Intellij Cannot resolve symbol on import

前端 未结 29 1740
耶瑟儿~
耶瑟儿~ 2020-11-30 18:10

This problem happens intermittently for different libraries and different projects. When trying to import a library, the package will be recognized, but the class name can\'

相关标签:
29条回答
  • 2020-11-30 19:13

    I had this recently while trying to use Intellij to work on NiFi, turned out the issue was that NiFi requires Maven >= 3.1.0 and the version that I'd checked out with (I guess my default) was 3.0.5. Updating the Maven version for the project fixed it, so in some cases Maven version mis-alignment can be a thing to look...I'd guess it's fairly unusual but if you get this far on the thread you're probably having an unusual issue :)

    0 讨论(0)
  • 2020-11-30 19:13

    file-> Project Structure -> Modules, find the module with problems, click it and choose the Dependencies tab in the right side. Click the green plus sign, try to add the jar or libraries that cause the problem. That works for me.

    0 讨论(0)
  • 2020-11-30 19:15

    I had a similar issue with my imported Maven project. In one module, it cannot resolve symbol on import for part of the other module (yes, part of that module can be resolved).

    I changed "Maven home directory" to a newer version solved my issue.

    Update: Good for 1 hour, back to broken status...

    0 讨论(0)
  • 2020-11-30 19:17

    File -> Invalidate Caches/Restart or rebuilding the project did not work wor me.

    What worked for my Gradle project was to "Refresh all Gradle projects" from the Gradle tab on top-right corner of IntelliJ v2017, using the yellow marked button shown below:

    0 讨论(0)
  • 2020-11-30 19:17

    After a long search, I discovered that a dependency was somehow corrupted on my machine in a maven project. The strange thing was that the dependency was still working correctly in the compiled java code. When I cleaned and rebuilt my maven dependency cache however, the problem went away and IntelliJ recognized the package. You can do this by running:

    mvn dependency:purge-local-repository
    

    Intrestingly, the source of my problem hence wasn't IntelliJ, but maven itself.

    0 讨论(0)
提交回复
热议问题