Eclipse 中覆盖注释的错误
我在 Eclipse 中的 @Override
注释方面遇到了一个恼人的问题。通常,当我在新 PC 上导入工作项目时,Eclipse 会将某些 @Override
注释标记为错误。如果我删除注释,一切都很好,并且 Eclipse 还指示这些方法正在重写父方法,但添加 Override 注释会再次导致错误。我目前正在开发一个 Android 项目,所以这可能是 Android 的问题,而不是 Eclipse 的问题。
I have a annoying problem with @Override
annotations in Eclipse. Often when i import working projects on a new PC, Eclipse marks some of the @Override
annotations as wrong. If i remove the annotations everything is fine and Eclipse also indicates that the methods are overriding the parents methods but adding the Override annotation causes the error again. I am currently working on an Android project so it might be a problem with Android and not with Eclipse..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这很可能是因为您正在 Java 1.5 和 Java 1.6 之间切换。在 1.5 中,您无法使用 @Override 标记接口实现,但在 1.6 中可以。
快速谷歌搜索发现了两个版本之间注释差异的很好解释:http: //www.techienuggets.com/CommentDetail?tx=38155
This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn't mark interface implementations with @Override, but you can in 1.6.
A quick Google search turned up this good explanation of the difference in this annotation between the two versions: http://www.techienuggets.com/CommentDetail?tx=38155
只需转到
并将其设置为 1.6,因为符号从 1.6 开始,因此如果编译级别低于 1.6,则会出现错误
just go to
and set it to 1.6 as notation starts from 1.6 so if compilence level will less then 1.6 it will gives error
有几个地方可以配置 Java 编译器设置。
一种方法是
Window->Preferences->Java->Compiler->Compiler Compliance Level->Compiler设置 1.6 或以上
。另一种方法是右键点击
Project->Properties->Java Compiler->JDK Compiler->JDK选择 1.6 或更高版本。
此外,您还可以取消选择“启用项目特定设置”,这将消除将来的 JDK 编译器合规性错误。
删除 JDK Versions 的多个实例,除非不同的项目需要它们。
There are a few places where Java Compiler settings are configured.
One way is to
Window->Preferences->Java->Compiler->Compiler Compliance Level -> set 1.6 or above
.Another way is right click on the
Project->Properties->Java Compiler->JDK Compliance -> Select 1.6 or above.
Also You can unselect "Enable Project Specific Settings" , this will eliminate future JDK compiler compliance errors.
Remove Multiple instances of JDK Versions , unless different projects need them.
确保使用的 Java SDK 是最新的,并且 Eclipse 使用正确的 SDK 版本(如果安装了多个 SDK)并使用正确的 SDK 版本处理您的 Android 项目...
Make sure the used Java SDK is up to date and that eclipse use the right SDK version (if you have more than one installed) and treats your Android project with the right SDK version...