views:

117

answers:

5

Hi all,

I'm trying to create a very simple webapp with maven and eclipse, but I'm having no joy at all, in fact the reverse of joy.

I go to File -> New Project, select Maven Project, and select the maven-archetype-webapp. When I finish the wizard, a webapp structure gets generated but with no 'java' directory under main, just resources and webapp.

So I right click on main and select new Class. The class gets created under resources (?!), and furthermore, there seems to be no compilation of it by java. I can make stupid errors and no syntax highlighting comes up. It's like java isn't recognizing it.

Alternatively I have tried creating a new 'java' directory under main where it should be, but still with the same non-existent java symptoms.

What gives? This is driving me insane..

Thanks all!

+1  A: 

There is an option to create a source directory in eclipse. Or you can go to build path under project properties, and add an existing directory as a source directory.

If you are going to use non-standard directory structure you will have to specify it in maven though

Rulmeq
+1  A: 

Anything else is likely to be down to the archetype and how you've configured your pom.xml. The directory structure you describe is identical to the one maven-archetype-webapp creates on the command line.

McDowell
+2  A: 

Simply create a java directory under main (i.e. src/main/java) and right-click on your project and select Maven > Update Project Configuration.

Pascal Thivent
A: 

a webapp structure gets generated but with no 'java' directory under main

Create src/main/java on your own.

furthermore, there seems to be no compilation of it by java. I can make stupid errors and no syntax highlighting comes up. It's like java isn't recognizing it.

after creating appropriate dir structure execute the maven command

mvn eclipse:eclipse 

then refresh the project in eclipse.

-SE

becomputer06
The OP is using m2eclipse, not the maven-eclipse-plugin
Pascal Thivent
A: 

Simply create a java directory under main (i.e. src/main/java) and right-click -> Build Path -> Use a Source Folder

:)

Linz