Configuring Hibernate and Spring for Standalone Application

girlcoderuk

This article is designed to fill a gaping hole in the Examples for Spring / Hibernate configuration and that is for Standalone Applications.

Usually all the demonstrations are for Web applications or J2EE applications, so this one is for a simple Command Line Application. I use Intellij Idea and Maven but i hope it works as easily if you are using Netbeans or Eclipse.

Ok Lets start out Easily:

Create a new Maven Project with no Archetype

<?xml version=”1.0″ encoding=”UTF-8″?>
<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.0http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.theresajayne.standaloneexample</groupId>
<artifactId>standaloneExample</artifactId>
<version>1.0-SNAPSHOT</version>
</project>

Idea will have created the pom file but nothing else do under src/main/java add a package for your system (mine is com.github.theresajayne/standaloneexample) and create a main class under there to match your project name

package com.github.theresajayne.standaloneexample;

public class StandaloneExample {
}

now lets return to the pom file, We need to add the Spring, Hibernate and…

View original post 841 more words