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
- Download, install and configure Java EE SDK 6 in your machine. Download Java
- Download and configure Apache Maven 3 in your machine.
- Download and run MySql 5. Download MySql
- Download and install Apache Tomcat. Download Tomcat
- Download and install Eclipse IDE. Download Eclipse
- Install EGit plugin into Eclipse IDE. Installing EGit plugin
Instructions
Download the project
- Create a user account in the github if you haven't done so.
- Log into github and fork the github repo into your own repo. Fork-a-repo guide
- Clone the forked repo into your local workspace by using EGit plugin.
- Import the working directory of the cloned repo as a project. The project will appear in the package explorer.
Prepare the database
- Create a database in the mysql with name hibnatedb.
- 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
- 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. - Make sure the username and the password for the database are correct.
Build the project
- Open the command prompt and navigate to the project folder.
- Execute the following command:
mvn clean install
- Once the command was executed successfully, a target folder should be created in the project.
- In the target folder there should be a file named spr-mvc-hib.war.
- Copy spr-mvc-hib.war into the Tomcat's webapps folder.
Preview
- Startup the tomcat server.
- Monitor the log file and verify that the spr-mvc-hib.war is deployed
- Once the server started up, go to http://localhost:8080/spr-mvc-hib to view the front end.