This tutorial is part of the Hibernate introduction series. This is to help setup and getting started with Hibernate. Needless to say, we need JDK. Our choice of IDE is Eclipse, build tool is Maven. You can do with Netbeans or any other editor. ANT or any other build tool is also fine.
Ensure that you have some version of JDK configured as below in Eclipse preferences.
If you have setup Maven correctly, you should have preferences similar to the following
Maven is a build tool by Apache, it will help to manage the dependencies better. Now, I will create Standard Java Project, add required JARs, compile and package using Maven. All of these listed tasks are executed by Maven behind you.
Following below steps are the needed steps for creating full-fledged Java Project with all required Hibernate libraries.
For now, your Hibernate project is created but still you need to add required dependencies/libraries that Hibernate requires to work.
For getting started with Hibernate, the required libraries are:
The projects Maven pom.xml is as below,
<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.javapapers</groupId> <artifactId>Hibernate-Sample</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>Hibernate-Sample</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.6.Final</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.31</version> </dependency> </dependencies> </project>
With this a basic shell project is ready for Hibernate based development. In the next tutorial we will see how to configure the Hibernate properties, session and connect the database.
This Hibernate tutorial was added on 08/10/2014.