A very useful yet simple reference for starting up a java project. However this content is very old and might be outdated.

7 years ago
Java
Spring
Hibernate

Main reference: http://www.javacodegeeks.com/2013/04/spring-mvc-hibernate-maven-crud-operations-example.html

Github: https://github.com/mjunaidi/spr-mvc-hib/tree/example

Preparation

  1. Download, install and configure Java EE SDK 6 in your machine. Download Java
  2. Download and configure Apache Maven 3 in your machine.
  3. Download and run MySql 5. Download MySql
  4. Download and install Apache Tomcat. Download Tomcat
  5. Download and install Eclipse IDE. Download Eclipse
  6. Install EGit plugin into Eclipse IDE. Installing EGit plugin

Instructions

Download the project

  1. Create a user account in the github if you haven't done so.
  2. Log into github and fork the github repo into your own repo. Fork-a-repo guide
  3. Clone the forked repo into your local workspace by using EGit plugin.
  4. Import the working directory of the cloned repo as a project. The project will appear in the package explorer.

Prepare the database

  1. Create a database in the mysql with name hibnatedb.
  2. Execute below SQL command or create a table with the same definition as below:
    CREATE TABLE `teams` ( `id` int(6) NOT NULL AUTO_INCREMENT, `name` varchar(40) NOT NULL, `rating` int(6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

Configure the properties

  1. Open file application.properties in order to change some setting properties. The full path of the file is in /src/main/resources/application.properties. To quickly open the file in the eclipse, simply push Ctrl + Shift + R and enter the file name into the prompt box's input field.
  2. Make sure the username and the password for the database are correct.

Build the project

  1. Open the command prompt and navigate to the project folder.
  2. Execute the following command: mvn clean install
  3. Once the command was executed successfully, a target folder should be created in the project.

  1. In the target folder there should be a file named spr-mvc-hib.war.

  1. Copy spr-mvc-hib.war into the Tomcat's webapps folder.

Preview

  1. Startup the tomcat server.
  2. Monitor the log file and verify that the spr-mvc-hib.war is deployed
  3. Once the server started up, go to http://localhost:8080/spr-mvc-hib to view the front end.