Remove @Override annotration解决

简介:

Michael Myers Nov 19 '10 at 15:17

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned more than 10 reputation on this site.

5 Answers

up vote 275 down vote accepted

Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).

Go to your project/ide preferences and set the java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from eclipse.

link | improve this answer
Thank you so much, never would have figured that out! –  Tim H  Nov 5 '09 at 4:02
Happy to help. Been bitten by the same myself ;) –  alphazero  Nov 5 '09 at 4:28
+1 for short and clear answer. –  OemerA  Oct 12 '10 at 8:38
Same issue here, thanks, great answer. –  DavidG  Dec 28 '10 at 15:54
2  
My project was set to 1.6, so I shot for the stars and set it to 1.5, rebuilt, then back to 1.6. Miraculously this resolved my issue. Thanks for pointing me in the right direction! –  Michael Krauklis  Feb 9 '11 at 20:43
show 6 more comments
feedback

With Eclipse Galileo you go to Eclipse -> Preferences menu item, then select Java and Compiler in the dialog.

Now it still may show compiler compliance level at 1.6, yet you still see this problem. So now select the link "Configure Project Specific Settings..." and in there you'll see the project is set to 1.5, now change this to 1.6. You'll need to do this for all affected projects.

This byzantine menu / dialog interface is typical of Eclipse's poor UI design.

link | improve this answer
+1 - this was driving me crazy. –  I82Much  Sep 8 '10 at 17:10
+1 Good followup. I wish the answers were consolidated. –  Justin  Nov 18 '10 at 12:43
3  
+! excellent supplement to the above answer –  Anand  Jan 21 '11 at 10:54
Great stuff! Thanks –  m6tt  Nov 19 '11 at 23:42
feedback

In case this happens to anyone else who tried both alphazero and Paul's method and still didn't work.

For me, eclipse somehow 'cached' the compile errors even after doing a Project > Clean...

I had to uncheck Project > Build Automatically, do a clean and build again.

link | improve this answer
欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,转载请注明出处!http://www.cnblogs.com/sunshine-anycall/archive/2012/01/06/2315058.html
相关文章
|
3月前
|
消息中间件 Kubernetes NoSQL
c++11 关键字 override 与 final
c++11 关键字 override 与 final
|
4月前
|
PHP
PHP public、protected、private、static、abstract、final、interface、implements 区别对比
PHP public、protected、private、static、abstract、final、interface、implements 区别对比
29 0
override 指示符
override 指示符
62 0
|
编译器
public <T> T method(T t)方法详解
public <T> T method(T t)方法详解
242 0
public <T> T method(T t)方法详解
List.remove 报错 UnsupportedOperationException
Java中List.remove(removeRange,clear类似) 报出 UnsupportedOperationException 的错误。原来该List是一个AbstractList,不支持增删改操作。
1202 0