Tuesday, July 12, 2011

Structs2 HelloWorld web Application

To follow this tutorial you need to have installed following applications on your computer.


1) Eclipse IDE : Eclipse Java EE IDE for Web Developers

2) Add m2eclipse Plugin to your Eclipse instance

3) Maven Automated build environment

4) Apache tomcat server 6

when you have those applications running on your computer you will be able to follow the instructions given below to create java web application using Struct2 framework.

First start eclipse IDE and create Maven Project. To create Maven Project follow following steps.

File -> New -> Other

This will open select a wizard window.

Selce Maven and then selcet Maven Project and then click next.

Then it will ask for project name and project location

From this window tic on default workspace location.

Click next

Now you need to select project archetype.

select maven-archetype-webapp. or type maven-archetype-webapp under filter section.

Click next

Provide Artifact ID. For this project i use  Structs2XMLConfigurationExample
provide Group ID. For this project i use com.vaanila.action


Now click finish.

Now you should be able to see the newly created project in the Project Explorer window.

Now , you have to add few plugins to pom.xml file created by maven automated tool for your project.

you need to add following configuration to the build element of the web application


<build>
    <finalName>Struts2Example</finalName>
    <plugins>
    <plugin>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.8</version>
    <configuration>
    <wtpversion>1.5</wtpversion>
    </configuration>
    </plugin>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
    </plugin>
    </plugins>
  </build>

After adding this configurations run from the command line

mvn clean install

This command will download the required jars for the project to your project location.

then run

mvn eclipse:eclipse

This will import the configuration to eclipse IDE.

No comments:

Post a Comment