Thursday, August 16, 2012

Add new struts2 maven project in eclipse

1. Click File > New > Project... 
2. New Project will be prompted. Choose Maven > Maven Project. Click Next.
3. New Maven Project will be prompted. Click next.
4. Choose Nexus Indexer for Catalog. highlight maven-archetype-webapp(Artifact Id) and click next.
5. Fill in the Group Id, Artifact Id, version and click Finish.
6. Set the tools.jar dependence in your pom.xml. 


                  <value>Sun Microsystems Inc.</value>
                  <systemPath>C:/Program Files/Java/jdk1.6.0_23/lib/tools.jar</systemPath>

This will solve the Missing artifact com.sun:tools:jar:1.5.0:system problem.

7. Add strut2
There are 2 ways to do it:

a. Right click the source folder, Maven > Add Dependency. Type struts2-core. Then, highlight the org.apache.struts struts2-core and click ok.

b. Add below in pom.xml


8. Add log4j and javassist dependencies.

** log4j is encouraged to be manually added to prevent Missing artifact log4j:log4j:bundle:1.2.16:compile

** Final pom.xml attached on below

9. Right click on the project: Run as > Maven install. This will build war file in the target folder of your project. 

10. Deploy the war file.