Getting “cannot find Symbol” in Java project in Intellij

前端 未结 24 850
清酒与你
清酒与你 2020-12-04 10:33

I make this call to a static singleton instance from the class GameManager.java.

HUD.getInstance().update(timeDelta);

HU

相关标签:
24条回答
  • 2020-12-04 11:17

    I had to right-click the project, and select "Reimport" under the "Run Maven" submenu.

    0 讨论(0)
  • 2020-12-04 11:17

    I was having the same problem except that I was importing the classes for which dependencies were not resolving somehow. I refreshed maven projects, Rebuild Project. It still did not resolve. Looks like IntelliJ was caching something incorrectly. I restarted IntelliJ and that resolved the dependencies. I guess it cleared the cache somehow.

    0 讨论(0)
  • 2020-12-04 11:19

    Sometimes the class you want is in the test source directory. Happened to me, anyway…

    0 讨论(0)
  • 2020-12-04 11:19

    I'm seeing a lot of answers proposing a build or a re-build but just in case this don't fix your problem just notice that IDEA can detect a method but it will not compile in case you have a new before as it will be expecting the instance.

    0 讨论(0)
  • 2020-12-04 11:19

    In my case, I had a problem with finding a class from another module. In pom.xml, I just had this dependency with <scope>compile</scope> specified. Removing this line helped.

    0 讨论(0)
  • 2020-12-04 11:23

    I had the same problem, and turns out I had never completely compiled the fresh project. So right-clicking and selecting Compile'' (shift-cmd-F9 on mac) fixed it. It seems the compile on save does not 'see' non-compiled files.

    Marking the src folder as source did not help in my case.

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