Eclipse 无法加载资源目录(构建路径问题)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5132588/
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
Eclipse cannot load resources directory (Build Path Problem)
提问by user496949
I found there is an exclamation mark in the icon of my project. I guess it is caused by the resources directory is not loaded.
我发现我的项目图标中有一个感叹号。估计是资源目录没有加载造成的。
Here is part of my .classpath file, anything can be wrong?
这是我的 .classpath 文件的一部分,有什么问题吗?
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
<classpathentry kind="src" path="src/main/java" including="**/*.java"/>
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
The problem Eclipse shows is
Eclipse 显示的问题是
Project 'dingdong' is missing required source folder: 'src/main/resources' dingdong Build path Build Path Problem
Project 'dingdong' is missing required source folder: 'src/main/resources' dingdong Build path Build Path Problem
回答by esaj
Just adding this here if someone stumbles on the same question: The problem was solved by refreshing the project (Selecting the project root and hitting F5), see comments.
如果有人偶然发现同一个问题,只需在此处添加:通过刷新项目(选择项目根目录并按 F5)解决了问题,请参阅评论。
Eclipse does not refresh the workspace projects by default when starting up. You can add an start-up option (the flag is -refresh, see herefor details) for performing a global refresh of the workspace on startup. This will reconcile any changes that were made in the file system since the platform was last run.
默认情况下,Eclipse 在启动时不会刷新工作区项目。您可以添加启动选项(标志是-refresh,请参阅此处了解详细信息)以在启动时执行工作区的全局刷新。这将协调自平台上次运行以来在文件系统中所做的任何更改。
Removing and re-adding the source folder to project Build path can be done like this:
将源文件夹删除并重新添加到项目构建路径可以这样完成:
- Right click on the source folder, select Build path -> Remove from build path
- Select the folder from the "normal" (non-source folder) -directory tree (usually shows way down in your project tree), right click the desired directory and select Build path -> Use as Source folder
- 右键单击源文件夹,选择构建路径 -> 从构建路径中删除
- 从“普通”(非源文件夹)-目录树(通常在项目树中向下显示)中选择文件夹,右键单击所需目录并选择构建路径 -> 用作源文件夹
回答by scottysseus
Refreshing the project, which is what the accepted answer suggests, failed for me.
刷新项目,这是公认的答案所暗示的,对我来说失败了。
Here is what I did to resolve this issue:
这是我为解决此问题所做的工作:
- Right click , and then select
Build Path -> Configure Build Path... -> Order and Export
- Look for the src/main/resources folder in the entries list. Mine was called
<my project folder>/src/main/resources
. - Move
<my project folder>/src/main/resources
to the bottom of the dependency list by selecting it and clicking the button titledBottom
.
- 右键单击 ,然后选择
Build Path -> Configure Build Path... -> Order and Export
- 在条目列表中查找 src/main/resources 文件夹。我的被称为
<my project folder>/src/main/resources
。 <my project folder>/src/main/resources
通过选择依赖项列表并单击标题为 的按钮移动到依赖项列表的底部Bottom
。
This resolved the issue for me. In my case, the resources
entry was above the src/main/java
and src/main/test
entries, which seems to have been causing problems.
这为我解决了这个问题。就我而言,resources
条目位于src/main/java
和src/main/test
条目之上,这似乎引起了问题。