Eclipse:“声明的包与预期的包不匹配",但是buildpath确实定义了声明的包 [英] Eclipse: "declared package does not match the expected package", but buildpath does define the declared package
问题描述
在名为my-project
的Maven项目中,eclipse不断告诉我
In a maven project called my-project
, eclipse keeps telling me
已声明的软件包"com.myself"与预期的软件包"main.java.com.myself"不匹配
尽管我已验证在项目的构建路径中,我有一个条目:
although I verified that in the project's build path, I have an entry:
my-project/src/main/java
Included: **/*.java
Excluded: (None)
Native library location: (None)
Ignore optional compile problems: No
那可能是什么问题?
最简单的解决方法是什么?
我怀疑eclipse设置文件出了点问题,因为在将项目导入到工作区并将其转换为maven项目后,我不得不手动更改了文件夹结构以获取Maven Web的常规文件夹结构项目.但可能是在这些更改期间,日食无法正确理解某些内容.
I suspect that something is wrong with the eclipse settings files, because after importing the project to the workspace and converting it to a maven project, I had to change the folder structure manually in to get the conventional folder structure of a maven web project. But it could be that during those changes, something was not understood properly by eclipse.
此外,maven能够构建我的项目(从Eclipse内部以及从命令行).
Also, maven is able to build my project (from within eclipse, as well as from the command line).
我只是从eclipse中得到那些编译错误.
I'm just getting those compilation error from eclipse.
P.S.我已经尝试过项目>清理,但是没有帮助.
P.S. I've already tried project > clean, but it did not help.
推荐答案
- 我将项目文件夹复制到了Eclipse工作区之外的某个地方.
- 然后我从Eclipse项目浏览器和工作区中删除了该项目.
- 现在,我用相同的名称创建了一个新的Java项目,并导入了我在(1)中保存的原始项目.
- 塔达!没有编译错误.
这篇关于Eclipse:“声明的包与预期的包不匹配",但是buildpath确实定义了声明的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!