eclipse 缺少构建路径条目:/src/test/java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29822787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Build path entry is missing: /src/test/java
提问by oddly
While running my java project on Eclipse Luna, I have some errors due to which I suppose related to this problem.I right click on the project, choose properties --> java build path --> source, I see a warning at the top:
在 Eclipse Luna 上运行我的 java 项目时,我有一些错误,我想这与这个问题有关。我右键单击项目,选择属性 --> java 构建路径 --> 源,我在顶部看到一个警告:
And it seems that I have forgotten to add this package at the beginning of my project.I want to add it now, but I cannot do it via "Add Folder" button.When I press "Add Folder" button, a window appears like this one:
而且好像我在项目开始时忘记添加这个包了。我想现在添加它,但我无法通过“添加文件夹”按钮来添加。当我按下“添加文件夹”按钮时,会出现一个窗口这个:
However, I believe I should add it under "Java Resources" on the tree:
但是,我相信我应该将它添加到树上的“Java 资源”下:
How can I modify this? Thanks for any help..
我该如何修改?谢谢你的帮助..
回答by Marvin
src/test/java
is just maven's default entry for any test classes. If you have (or plan to have) test classes, you can create a new folder structure test/java
below your src
folder and afterwards select it in the dialog you've shown. If you don't plan to have any test classes, you can safely remove the entry from the build path.
src/test/java
只是 maven 对任何测试类的默认条目。如果你有(或计划有)测试类,你可以test/java
在你的src
文件夹下创建一个新的文件夹结构,然后在你显示的对话框中选择它。如果您不打算拥有任何测试类,则可以安全地从构建路径中删除该条目。
回答by Diego Santa Cruz Mendezú
This worked for me:
这对我有用:
mvn clean install
I hope it helps
我希望它有帮助
回答by free
How to add missing src/test/java folder to the maven project in Eclipse
如何将缺少的 src/test/java 文件夹添加到 Eclipse 中的 maven 项目
1) Create a folder test/java under src folder 2) Right click on the project and choose Maven --> Update Project --> choose for Force update of Snapshot/Releases and click ok. Now test folder should appear as src/test/java in Eclipse project explorer
1) 在 src 文件夹下创建文件夹 test/java 2) 右键单击项目并选择 Maven --> Update Project --> 选择 Force update of Snapshot/Releases 并单击确定。现在 test 文件夹应该在 Eclipse 项目资源管理器中显示为 src/test/java