Eclipse cannot load resources directory (Build Path Problem)
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?
<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
Project 'dingdong' is missing required source folder: 'src/main/resources' dingdong Build path Build Path P开发者_StackOverflowroblem
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.
Eclipse does not refresh the workspace projects by default when starting up. You can add an start-up option (the flag is -refresh, see here for 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.
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
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
.
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.
精彩评论