Sunday 10 May 2009

Struts2 web framework - Set up Struts2 with Maven

These are the minimum requirements to create a HelloWorld Struts application.

Here is the pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eleannita</groupId>
<artifactId>blog</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>blog</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.9</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
</project>

You can now execute that using Jetty. It is an lightweight servlet container and you can easily run jetty using maven with the command:
mvn jetty:run
Voila! :)

No comments:

Post a Comment