`
jaesonchen
  • 浏览: 311438 次
  • 来自: ...
社区版块
存档分类
最新评论

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了。

 

 

Just go into the build path and the source path to be src/prefix1 instead of src.

It may be easiest to right-click on the src directory and select "Build Path / Remove from build path", then find the src/prefix1 directory, right click and select "Build Path / Use as source folder".

 

分享到:
评论

相关推荐

    如何使用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通常被认为更易于理解和使用,更适合小型到...

    Maven3实战笔记04Maven的生命周期和插件

    5. **package**:执行Default生命周期中的`package`阶段,调用`maven-jar-plugin`的`jar`目标来打包项目。 6. **install**:执行Default生命周期中的`install`阶段,将构建好的包安装到本地仓库。 通过这种方式,...

    codeblocks中报错:'to_string' was not declared in this scope解决方案

    在Code::Blocks中遇到“'to_string' was not declared in this scope”的错误,通常是由于编译器版本过低或者没有包含正确的头文件所导致的。`std::to_string`是C++11标准引入的一个函数,用于将数字转换为字符串。...

    The Go Programming Language(Addison,2015)

    The book does not assume prior knowledge of Go nor experience with any specific language, so you'll find it accessible whether you're most comfortable with JavaScript, Ruby, Python, Java, or C++. ...

    The.Go.Programming.Language.0134190440.epub

    The book does not assume prior knowledge of Go nor experience with any specific language, so you’ll find it accessible whether you’re most comfortable with JavaScript, Ruby, Python, Java, or C++. ...

    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...

    variable declared but not used(解决方案).md

    variable declared but not used(解决方案).md

    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. ...

    JSP Simple Examples

    Suppose if we have declared an array of type int then the array will take only the int values and not any other data types. We can find find out the length of the variable by using the variable ...

    mysql 客户端软件 mymanager_lite

    The software contains all files of the installation package except for the "Dump" folder contents. This LICENSE AGREEMENT ("LICENSE") defines what the USER may do with the SOFTWARE, and contains ...

    DevExpress VCL 13.2.5 D7-DXE6 FullSource

    •Q584524 - Ribbon - QAT doesn't display the double arrow if the Ribbon control's PopupMenuItems set does not include items •Q581962 - Ribbon - Switching between maximized MDI child windows using the...

    SCJP 6 question demo

    - **Unchecked Exceptions and Threads:** In Java, if an unchecked exception is thrown by a thread, it does not cause the program to terminate immediately but rather propagates up the call stack until ...

    prbs check

    - The module is declared as `modulePRBS_CHK(CLK, RESET, DIN, DVAL, LOCK);`. It takes five inputs: `CLK` (Clock signal), `RESET` (Reset signal), `DIN` (Data In), `DVAL` (Data Valid Strobe), and one ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    It is important to know that functions are not always inlined even if they are declared as such; for example, virtual and recursive functions are not normally inlined. Usually recursive functions ...

    ObjCRuntimeGuide

    - **Message Forwarding:** If an object receives a message that does not match any of its methods, the runtime system can forward the message to another object. This process involves a series of steps,...

    ssd3选择题答案大全

    - **正确答案**:(b) println appends a newline to the end of its output, but print does not - **解析**:`println`方法会在输出结束后自动添加一个换行符,而`print`方法则不会添加换行符。 #### 5. What will...

Global site tag (gtag.js) - Google Analytics