eclipse 中匯入源碼出現 The declared package does not match the expected package的解決方案

來源:互聯網
上載者:User

eclipse 匯入項目,有時候會出現 java 檔案表徵圖由實心J變成空心J的問題,這個時候是不能編輯源檔案的,至於解決辦法就是右鍵該檔案夾 – >BuildPath –> use as source folder

當以上問題解決後,如果你選擇的檔案路徑不對,開啟一個 java 檔案就會出現首行的包命報錯,The declared package does not match the expected package,這個主要是右鍵檔案的時候,沒有定位到正確的位置,這個問題的解決辦法就是先從 source folder 移除掉你添加的檔案,然後定位到你包名的上一級目錄,如 java檔案包名為 com.eaphy.platform.patch.slogon.action ,報錯提示包名應該是 java.com.eaphy.platform.patch.slogon.action ,那麼,右鍵的檔案夾就應該在 java 這一級,然後 BuildPath –> use as source folder 這樣就ok了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.