如何處理Eclipse錯誤訊息 The declared package does not match the expected package

i042416發表於2018-11-04

我從github下載了一個開源專案後,匯入到自己Eclipse之後,遇到了這個煩人的錯誤訊息:
The declared package "com.sap.smartService" does not match the expected package "main.java.com.sap.smartService"


如何處理Eclipse錯誤訊息 The declared package does not match the expected package

這是我的專案檔案目錄:


如何處理Eclipse錯誤訊息 The declared package does not match the expected package

解決方案:對專案點選右鍵,選擇Properties->Build Path, 發現src資料夾被設為build path。


如何處理Eclipse錯誤訊息 The declared package does not match the expected package

首先右鍵src資料夾,選擇Remove from Build Path將其從build path中移除:


如何處理Eclipse錯誤訊息 The declared package does not match the expected package

然後選擇src/main下面的java資料夾,設定成build path,重啟Eclipse:


如何處理Eclipse錯誤訊息 The declared package does not match the expected package

錯誤即消失:


如何處理Eclipse錯誤訊息 The declared package does not match the expected package

要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2218632/,如需轉載,請註明出處,否則將追究法律責任。

相關文章