Hibernate Development Environment with Eclipse and Maven

Last modified on October 8th, 2014 by Joe.

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.

Tools used to setup the environment:

Important part is the configuration of the needed Hibernate libraries. If you are new to Maven, go through detailed information for Maven download and setup and Maven in 10 minutes tutorial.

JDK Configuration:

Ensure that you have some version of JDK configured as below in Eclipse preferences.

Eclipse-JDK-1.67

Maven Configuration:

If you have setup Maven correctly, you should have preferences similar to the following

Eclipse-Maven-3.0.43

Create Maven Project

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.

Create-Maven-Project-Expand-Maven-No

Create-Maven-Project-Choose-Maven-Ar[1]

Create-Maven-Project-Filling-In-All-[1]

Create-Maven-Project-Final-View3

Add Required Dependencies for Hibernate

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,

Maven pom.xml for Hibernate and MySql dependencies

<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.

Comments on "Hibernate Development Environment with Eclipse and Maven"

  1. […] an example Hibernate application and you need to setup the development environment. Follow the linked tutorial to setup the project and put the following Java class file and run […]

  2. […] Setup the Hibernate development environment by referring this previous tutorial. […]

  3. Ankita says:

    Where is the src/main/resources folder

  4. Mansi says:

    Very nice description!!

  5. Nikesh Patel says:

    That’s One is Fantastic Description…
    Thanks man

Comments are closed for "Hibernate Development Environment with Eclipse and Maven".