The declared package does not match the expected package “”

前端 未结 21 2028
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 09:05

I am using Eclipse and have not used Java for sometime. However, I can compile my code on the command-line just fine and generate the necessary .class files. In

相关标签:
21条回答
  • 2020-12-01 09:24

    I was using Spring Tool Suite 4. Not able to figure out the issue. The directory structure was according to the package name.

    But cleaning the project helped me.

    0 讨论(0)
  • 2020-12-01 09:29

    This happened to me when I was checking out a project from an svn repository in eclipse. There were jar files in my .m2 folder that eclipse wasn't looking at. To fix the issue I did:

    right click project folder Configure > Convert to Maven Project

    and that solved the issue.

    0 讨论(0)
  • 2020-12-01 09:30

    Create a new package under your project called "Devices" and place your class in it. This is equivalent to the class being placed in a directory called "Devices" in your project source folder.

    0 讨论(0)
  • 2020-12-01 09:32

    Got the same kind of error but my package was absolutely correct. When I just closed and opened my editor, the error disappears. Hope this might help in some scenarios.

    0 讨论(0)
  • 2020-12-01 09:32

    I faced this issue too when I had imported an existing project to eclipse. It was a gradle project, but while importing I imported it as regular project by clicking General-> Existing Projects into Workspace. To resolve the issue I've added Gradle nature to the project by :::: Right click on Project folder -> Configure-> Add Gradle Nature

    0 讨论(0)
  • Make sure that Devices is defined as a source folder in the project properties.

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