Platform:
- windows 7- 64 bit
- java version "1.7.0_40"
- apache-maven 3.1.0
- eclipse Kepler 4.3.1
- m2e - Maven Integration for Eclipse- http://www.eclipse.org/m2e/download/
- artifactory-3.0.3
- tomcat7-maven-plugin
- jetty-maven-plugin
- with parent pom
In this tutorial I want to create maven-compatible eclipse dynamic web project with parent pom.
I have artifactory-3.0.3 as maven repository server running for caching artifacts.
Instead of setting up tomcat or other containers I choose jetty-maven-plugin and tomcat7-maven-plugin.
I can't get project running on jetty embedded as I guess it might be related to windows path file problem.
|
create new dynamic web project
|
|
give a name and next |
|
delete 'src' folder and create new folders as above and
change default output folder as well |
|
change content directory as above and tick to generate web.xml deployment descriptor
click finish |
|
This is how it looks like after you click finish button.
It is still not maven project. |
|
This is M2 eclipse plugin feature.Just right click on the project
Configure-Convert to Maven Project |
|
Normally I deselect of all them as I don't need and click to finish.
This will create your pom file and maven project
I am not sure but this must be part of M2 eclipse plugin feature
Maybe you can explain why this comes up or whether I need it or not. |
|
Now it is maven project. |
|
Right click on "webapp" directory then
New-Other |
This is the contents of web.xml
This is the contents of pom.xml
As you are aware I use parent-pom file for my projects.There's another how-to about this parent-pom file
here.
|
To run project on tomcat you need to create run configuration for tomcat maven plugin.
When you right click on pom.xml there are two "maven build" menu.
However the one ending with "..' is for the first time configuration.
After you create tomcat:run configuration you can use the one without "..' directly.
If you create more than one eclipse lists all run configurations.
At the bottom there's run configurations menu. |
Here are the configurations for tomcat and jetty maven plugins.
|
works http://localhost:8080/
don't work http://localhost:8080/test1/index.jsp http://localhost:8080/test1 |
Click to run tomcat:run window
|
You can start web browser that the arrow shows above. Just the copy url painted in blue on the console. You can stop embedded tomcat with the red open the arrow shows below |
When I try to run with jetty maven plugin it fails.I even try with given whole url including index.jsp
Here is the error message on console.
Please feel free to make suggestions corrections contributions etc.All is appreciated.
References:
www.cloudchamp.com/2010/08/creating-maven-web-project-in-eclipse.html