Search code examples
javaeclipsemavenm2eclipse

eclipse does not recognize package


(HELIOS Eclipse, m2eclipse is installed from the update site)

I am creating a new web application: File->New->Other->Maven->Maven Project, Next, Next, then selected maven-archetype-webapp, added a Group Id and Artifact Id. Now in the newly created project I want to add a new java package: right click on , new -> package. Inserted package name and click on finish.

And I'm getting a new folder. Eclipse does not recognize this as a package.

What should I do to make Eclipse recognize that folder as a package?

Many tia,

DHR


Solution

  • The maven-archetype-webapp does not generate a src/main/java folder by default and if you want to add Java sources in your webapp, you need to create src/main/java yourself.

    Once this directory has been created, right-click on your project and then use Maven > Update Project Configuration and it will get added as source directory. Then you'll be able to add sources.

    Last thing, either use the maven-eclipse-plugin or use m2eclipse, not both, they are mutually exclusive.