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