Reputation: 16147
I was trying to generate a Simple Spring-MVC project using this this tutorial
However. upon importing the project in eclipse. there were several errors(well for me atleast)
First is this.
The packages are colored white. what I was expecting is the packages should be brown, like the normal projects in Eclipse.
Next. When Implemented the interface Named IndexController. it told me this error
"The Resource is not on the build path of a Java Project
what have I done wrong?
Upvotes: 0
Views: 378
Reputation: 135802
Your .java
files are in the resources
folder. They should be at a /java/
one.
The workaround is shown below, but first, understand what's going on:
In the Maven default folder structure, Java source files (.java
) should be in the
/src/*/java
folders, such as /src/main/java
and /src/test/java
.
The /src/*/resources
folders are reserved for resources to be used by the program, like configuration/properties files, images and so on:
src
|--main
| |--java
| | |--com
| | | |--mypackage
| | | |--MyClassA.java
| | | |--submypackage
| | | |--SomeOtherClass.java
| | |--net
| | |--netpackage
| | |--MyNetClassA.java
| |--resources
| |--myAppConfig.xml
|--test
|--java
| |--com
| |--anotherpackage
| |--AnotherClassTest.java
|--resources
Create a /java/
source folder and place your .java
files there:
src/main/java
:The src/main/java
should be created. Move the packages (the com.todolist.*
items) with the .java
files there.
If you can, just to make sure Maven/Eclipse catches up to the new structure: right-click your project and click Maven
-> Update Project...
:
Upvotes: 1