eclipse使用import导入源代码到项目中或者通过svn检出等方式导入源码到项目中,控制台容易出现大量错误。
但同时直接使用ant脚本进行编译则能编译成功。
这个时候请不用担心,打开错误可以看到在很多类的开头部分:package出现错误,提示为:
The declared package does not match the expected package
错误的原因是:
eclipse中包的定义一般是通过package包名产生,而不是通过文件的层次来定义。eclipse使用import导入源码时,导入的是文件结构而不是包形式,故报错。
解决方法:
点击> properties > java build path > source > add folder > select src/XXXX
然后重新编译就ok了。
Just go into the build path and the source path to be src/prefix1 instead of src.
It may be easiest to right-click on the src directory and select "Build Path / Remove from build path", then find the src/prefix1 directory, right click and select "Build Path / Use as source folder".
本文介绍了解决Eclipse导入源代码时出现的包定义错误问题。当通过import或SVN检出源码时,控制台可能会显示大量错误提示。文章提供了一种简单的方法来修正这些错误,并确保项目的正确构建。
6104

被折叠的 条评论
为什么被折叠?



