user446249
user446249

Reputation: 23

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

Upvotes: 2

Views: 15901

Answers (2)

Pascal Thivent
Pascal Thivent

Reputation: 570365

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.

Upvotes: 5

greuze
greuze

Reputation: 4398

It should work. You can mark the folder containing the package as "source folder" in eclipse, but only as a fast solution...

I usually work with eclipse wihout m2eclipse, and I run mvn eclipse:eclipse to generate the eclipse project. Maybe you can manually fix this running the command now (from eclipse with the plugin or from mvn directly).

Upvotes: 2

Related Questions