HibernateJavaStruts2

Struts 2, Hibernate 4 and MySQL Integration with Maven (Part1)

In this tutorial we will create a web application using Struts2, Hibernate 4 and Maven.

We will create a page where we can add an Employee to a MySQL database. The application will be deployed on Tomcat server.

First of all, lets create a Struts2 project using following Struts2 Blank archetype from Maven.

If you need help downloading maven, you can refer to this post :

Maven Basics

After Maven is installed, make sure JAVA_HOME is setup to your java installation folder and Maven bin folder is added to PATH variable. The instructions can again be found in post referred above.

Now, run the following from the command line :

mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/
This will start archetype catalog download in Interactive mode :
maven
Let’s select option 1 here to choose Struts 2 Archetype – Blank.

Now provide the below for next options(you can add your own names here) :

groupid : Struts2Hibernate

artifactid : Struts2HibernateApp

version : 1.0–SNAPSHOT

package : techkatak

Enter “Y” to confirm and your project will be ready.

Now open the project in Eclipse by selecting File -> Import -> Existing Maven projects and then select the project you created using Maven. Here are some screenshots for the same :

import

projectimport
 If you deploy the project now on server, and enter the following url in the browser
http://localhost:8080/Struts2HibernateApp

 The browser will display the text

struts2up

 

In the second part of this tutorial, we will see how to modify this application to create the New Employee registration page and in the last part of the tutorial, we will integrate hibernate and maven.

Here is the link to part 2 of this tutorial :

Struts 2, Hibernate 4 and MySQL Integration with Maven (Part 2)

© 2015, www.techkatak.com. All rights reserved.