Search code examples
servletsmavenmaven-3m2eclipseeclipse-wtp

Eclipse Indigo and Maven : Unable to find src/main/java in dynamic web project


I've been using Eclipse indigo with m2e and m2e-wtp installed.

I created a dynamic web project using m2e by selecting maven-archetype-webapp. Now the problem is, I could not see src/main/java, src/test/java and src/test/resources in the created structure. Here is a snap of the project.

enter image description here

I stumble around and found this link. I created required directories on file system. Now the question is ideally where should I add "Source Folder" for each directories(src/main/java, src/test/java and src/test/resources)? Should I add them under "Java Resources" or somewhere else?

Thanks


Solution

  • That's exactly how we do it. src/main/java, src/test/java and src/test/resources under java resources -> new source folder

    Don't forget to add your src/main/java path and the maven dependencies to the deployment assembly of your project if you want to run the web app from eclipse via tomcat.

    EDIT

    Concerning Eclipse Deployment:

    If the project is already facetted as a Dynamic Web Project like yours, you'll need to add a Server in the Server view (We use Tomcat 7 and reference a local tomcat copy in the server setup)

    Then you add the web projeect to the server (add/remove on the server)

    In the project properties you'll need to add the src/main/resources and src/main/java folders to your deployment assembly as well as the maven dependencies.

    We also use a src/main/webapp folder instead of the webcontent folder that is automatically created. This holds the web resources, WEB-INF and views and will be added to the deployment assembly as well and mapped to the root path '/'

    Now you'll run an install on your app and then select 'run on server'