The declared package does not match the expected package
生活随笔
收集整理的這篇文章主要介紹了
The declared package does not match the expected package
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
eclipse使用import導入源代碼到項目中或者通過svn檢出等方式導入源碼到項目中,控制臺容易出現大量錯誤。
但同時直接使用ant腳本進行編譯則能編譯成功。
這個時候請不用擔心,打開錯誤可以看到在很多類的開頭部分:package出現錯誤,提示為:
The declared package does not match the expected package
錯誤的原因是:
eclipse中包的定義一般是通過package包名產生,而不是通過文件的層次來定義。eclipse使用import導入源碼時,導入的是文件結構而不是包形式,故報錯。
解決方法:
點擊> properties > java build path > source > add folder > select?src/XXXX
然后重新編譯就ok了。
轉載于:https://www.cnblogs.com/davidwang456/p/3554350.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的The declared package does not match the expected package的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阅读redis源代码的一些体会
- 下一篇: Eclipse error: “The