Java @override報錯的解決方案

來源:互聯網
上載者:User

標籤:override   紅色叉   eclipse   

背景:

Myeclipse中出現@Override錯誤,必須刪除此標誌,項目才可以編譯通過,但是本來這個方法就是要重寫的,為什麼會報錯呢


原因:

jdk1.5(5.0)之前這個就有,算是Bug,jdk1.6(6.0)版本之後修複了這個Bug。


解決方案:

把工程編譯時間使用JDK1.6版本可以解決。

具體操作:

Myeclipse中 Window-->Preferences-->Java-->Compiler-->Configure Project Specific Settings -->選中項目-->OK-->1.6


PS:如果按照上面操作後還有紅色XX,開啟Eclipse的Navigator視圖,找到你項目中的.settings目錄,然後開啟org.eclipse.wst.common.project.facet.core.xml檔案:
<?xml version="1.0" encoding="UTF-8"?><faceted-project>  <fixed facet="wst.jsdt.web"/>  <fixed facet="jst.web"/>  <fixed facet="java"/>  <installed facet="java" version="1.5"/>   <!--刪掉-->  <installed facet="jst.web" version="2.5"/>  <installed facet="wst.jsdt.web" version="1.0"/></faceted-project>

刪除有關JDK的資訊。儲存,重新整理項目即可。

參考文章:http://jingyan.baidu.com/article/cbcede07320afa02f40b4d0a.html


Java @override報錯的解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.