Original link: http://www.cnblogs.com/davidwang456/p/3554350.html
The console is prone to a large number of errors when eclipse imports the source code into the project using import or through SVN checkout and other ways to import the source into the project.
However, compiling directly with the ant script will compile successfully.
This time please don't worry, open errors can be seen at the beginning of many classes: Package error, prompt:
The declared package does don't match the expected package
The cause of the error is:
The definition of a package in eclipse is typically generated through the package name, rather than through the hierarchy of the file. Eclipse imports the source code using import, the import is the file structure rather than the package form, so error.
Workaround:
Click > Properties > Java Build path > Source > Add Folder > selectsrc/XXXX
And then recompile is OK.
The declared package does don't match the expected package