`
zhouqiang128
  • 浏览: 96422 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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了。
分享到:
评论

相关推荐

    如何使用eclipse打开已有工程.docx

    The declared package does not match the expected package appendixaStringer.java Thinking in Java/appendixaline 12022 年 11 月 11 日 14:11:20 3870 可以添加 package appendixa 命令来解决。 在运行程序时...

    如何使用Eclipse导入并运行源码

    - **包声明不匹配**:如果出现类似`The declared package does not match the expected package appendixa Stringer.java Thinking in Java/appendix`这样的错误,说明源代码中的包结构与实际存放位置不符。...

    spring boot shiro demo项目

    Spring Boot Shiro Demo项目是一个基于Spring Boot框架与Apache Shiro实现的权限管理示例,旨在帮助开发者快速理解和应用Shiro进行权限控制。相比Spring Security,Shiro通常被认为更易于理解和使用,更适合小型到...

    a project model for the FreeBSD Project.7z

    The vision is “To produce the best UNIX-like operating system package possible, with due respect to the original software tools ideology as well as usability, performance and stability.” The ...

    acpi控制笔记本风扇转速

    _HID does not match the predefined PCI Root Bridge IDs, the _CID list (if present) is now obtained and also checked for an ID match. Implemented additional support for the PCI _ADR execution: up...

    Senfore_DragDrop_v4.1

    * The Shell Extension components does not support C++ Builder 4. For some strange reason the components causes a link error. * There appear to be sporadic problems compiling with C++ Builder 5. ...

Global site tag (gtag.js) - Google Analytics