Getting “cannot find Symbol” in Java project in Intellij

前端 未结 24 849
清酒与你
清酒与你 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:05

    I use maven in my project. For some reason IntelliJ was giving me these kind of wierd errors. I ran mvn clean and tried a resync and these errors disappeared.

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

    I know this is an old question, but as per my recent experience, this happens because the build resources are either deleted or Idea cannot recognize them as the source.

    Wherever the error appears, provide sources for the folder/directory and this error must be resolved.

    Sometimes even when we assign sources for the whole folder, individual classes might still be unavailable. For novice users simple solution is to import a fresh copy and build the application again to be good to go.

    It is advisable to do a clean install after this.

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

    For my case, the issue was with using Lombok's experimental feature @UtilityClass in my java project in Intellij Idea, to annotate a class methods as "static". When I explicitly made each method of the class as "static" instead of using the annotation, all the compilation issues disappeared.

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

    Since this is the first hit on Google searching for "intelliJ cannot find symbol" error, I'm gonna throw in my solution as well.

    The problem for me was that my project originated from Eclipse, and some files contained dependency on classes that were generated in src/generated-sources by specifications in pom.xml. For some reason, this was not properly executed when I first opened the project and rebuilding/re-importing did not help, so the files were never generated.

    The solution was to right-click on the module, and select Maven -> Generate Sources and Update Folders That solved the issue and I could compile.

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

    For me was a problem with Lombok, because it requires Annotation Processing to be enabled. You can find this checkbox on Settings > Build > Compiler > Annotation Processors

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

    This is likely to be your ../src folder is not marked as a "source" folder in Intellij IDEA, so it doesn't know to look there to find your class. You can right click the folder in the project explorer and choose "mark as source folder" to fix this.

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