Adding Hibernate dependency into Maven Project
Searching in the internet, I didn’t find an useful page explaining how to add hibernate depency into Maven. Although it seems an easy setup, I faced some problems that I’ll describe below.
First of all, I’d like to say that I’m using M2ECLIPSE plugin for Eclipse. There’s a simple instruction of how to install and use it here.
Even if you aren’t using M2ECLIPSE, you can follow this topic. I’ll show up the pom.xml file generated by the plugin.
Creating the PROJECT through Maven 2
The first thing to do is to create the project. You can use the Maven-archetypes to do that. There’re archetypes for desktop project, web projects, struts 2 projects and so on. Usually when you use the archetypes, it brings for you by default, the JUnit dependency already installed. Anything like this:
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8</version> <scope>test</scope> </dependency>
Note: You can edit this entry and change the JUnit’s version to 4.5 (the latest).
Adding Hibernate dependency
You can add the hibernate dependency either editing the pom.xml file or adding it through M2ECLIPSE. In POM.xml, simple add the following:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.6.ga</version> </dependency>
Through M2ECLIPSE, right click on POM.xml file, go to Maven -> Add Dependency. Type org.hibernate into input file and double click into org.hibernate result. That process will add the same code above into POM.xml
Note: When I’ve done it, I had problem with the jta 1.0.1B jar file. To fix it, I had to download it and save it into jta folder manually.
Adding Hibernate-Annotations
If you’re a normal person you won’t waste time editing XML, because of this you’re going to use Annotations instead, am I right? Hence, you must add the Hibernate-annotation dependency in your project as well.
To do that, edit the pom.xml file and add the following:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.4.0.GA</version> </dependency>
You can also add it through M2ECLIPSE. Repeat the process above and choose the hibernate-annotations rather than hibernate.
Adding slf4j-log4j12 dependency
Here is the trick. Although the two steps above are correct, you still need to add another dependency. org.hibernate adds the API slf4j, but it adds the wrong version. You must add the slf4j-log4j12 that is required by hibernate. To do that, as usual, add the following code into pom.xml:
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.5.2</version> </dependency>
or you can do the same through M2ECLIPSE.
Full POM.XML file
After all changes, you should have a POM.xml file like 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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>TestHibernate</groupId> <artifactId>Testhibernate</artifactId> <packaging>jar</packaging> <version>0.0.1-SNAPSHOT</version> <name>Testhibernate</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.6.ga</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.4.0.GA</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.5.2</version> </dependency> </dependencies> </project>
If you’re using the M2ECLIPSE, you can see all dependencies through its editor. Double click into POM.XML file and go to Dependency Hierarchy tab. You should see a screen like below:
Conclusion
As described above, the trick in this integration with the org.slf4j dependency. After you solve that problem, the integration works perfect. Both frameworks are awesome and this post teachs you in the integration of them.
I hope this topic be useful for anyone. If you have any question or comment about it, fell free to leave your message below.


Brazilian guy, IT Specialist, Linux and Mac User. Work with Java/JEE and IBM Products, such as: WebSphere and DB2. Like studying Ruby, Android and IOS. Also, I like playing tennis, however I am not good enough. Write a post in this blog once a year. Follow me on twitter if you understand portuguese: @jairrillo.
Hi,
I am using NetbeansIDE 9.1.I have a problem with the glassfish v3 server. Actually it uses two same jar files in different paths with different version.So while running my application,it shows a conflict. Also the version of the jar is 1.4 and my application requires 1.6. Though I had deleted those two 1.4 versions in the path and added the 1.6 version in the library, the server is trying to refer to the location(where I had deleted) and again causing the problem. I dont know how to upgrade the particular jar file(since it is present within another jar file).
I searched the net and tried to change the jars using jar uf command but I am not able to change it (as this due to jar within other jar).
Could you help me to figure out the issue.
If you need any additional information please let me inform.
Regards,
Sangita
Подскажите где лучше заказать рекламу сайта?
Набрел на один интересный сайтик.
Занимаются рассылками email, доски объявлений, вывод в ТОП -10 гугла…
Кто нибудь сталкивался? Что эффективней?
paul newman movie roles http://movieszone.eu/actor/128497/Maria-Rangel.html Maria Rangel if we were a movie
reputation defender
I like this forum because of posts like thisvery much appreciated particularly with what i will be trying to perform.
Does any one have any further reading? Where is the best place to get started here on this website?
http://cardetailingperth.wikispaces.com/
http://www.polanie.info
scott tucker, a good novice received from Leawood, Kansas created background with the 24 hours about The Mans from the 30 days connected with June really. She is the main particular person coming from U . s citizens to get allowed to drive among the list of 200-mph diesel multi-million piece style of Audi. He was particularly extremely fast.
From forty four years throughout 2006, Scott Tucker’s career inside off road racing launched. Previously the period, he previously in no way ran just before or simply have you been to some nationality observe. During this 12 months, the very first ever sold, the particular North american appeared to be authorized by means of Audi to push their R10 diesel-powered prototypes (200-mph) – about the most pricey as well as advanced sporting automobile ever made. He or she drove that from the most challenging in addition to lengthiest race previously. Even though the person did not currently have previously practical knowledge, your dog does just clearly.
Le Mans might be an essential truck contest. It event which unfortunately comes about even on a routine from nine kilometers and even involved driveways constructed towards the pretty purpose and also French tracks that have been re-designed for off road racing. All the competition is normally a day extended along with the victorious one the year of 2010 created 397 laps with a smaller here one hundred and forty mph; this is concerning way away concerning Big apple as well as Liverpool. Rushing passenger cars mostly run inside speeds up towards 210 mph along with around relating to the lengthiest direct within the path which is certainly only a filter court two-lane this really is not open from.
Within the last few 11 many years, Audi appeared to be successful during the Le Mans though the hard work of the Company because of Denmark was basically pretty shut down; they are tentative with getting just about anyone who might be not only a comprehend victorious associated with any engine’s wheels on their vehicles. They are really even more unwilling for you to allow customers who will be definitely not Europeans drive their particular cars and trucks. What this is actually telling is for which you are unable to basically go to People from france, place finances every now and then, and uncover they are driving a fabulous high-level prototype. Talent needs to be proven.
Tucker features this approach ability the fact that the Corporation is looking to get. Inside the a number of quite a few years for this off road racing occupation the person was initially linked to 91 wonderful happenings. Though she basically arrived to the game for the reason that the person saw the application as some thing excitement to do, he / she runs behind the wheel how much time a median would probably inside a decade. During that moment, your dog has been successful with thirty awesome races as well as started the actual podium a complete for 52 periods.
The Le Mans backrounds are popular to get absolutely eradicating autos additionally car owners. Your vehicle in which Tucker driven is demolished though this individual organize a great past experiences inside an item that most people merely dream about.
must look at this to take huge discount for more detail
Of the presidential candidates he is the only one who steps out of the political establishment, and as a result is largely ignored by the mainstream media.
visit us