So here I open Eclipse. It's a brand new workspace as you can see that there are no projects. So let's quickly get started with the eclipse Maven project by going to File New and then say Maven project. In the first dialog box, I'm going to click on this create simple project by skipping archetype selection. Next, the group ID, I can do anything that identifies my company or my organization. I'm going to type your code on the note, which is the reverse of my website, we know.co artifact ID, I'm going to give it as hibernate dot training.
And then I click on Finish. And the Maven project is now created here. For some reason, Maven sets the project's JDK version to one dot five. Let's first change that to one dot eight by going to project properties, Java build path, and then go to the libraries. Notice here it says JT SC one dot five, I double click on the same and then from the drop down, I'm going to say J two SC one dot eight. And then say finish.
Since we are going to connect our Java application to the h2 database server, let's also add the type four driver wire this add external jar, I go to my home directory here. And then there is a hitch to under h2, there's a bin, and then there is a h2 one dot four dot 197 dot jar. Click on Apply and close. And it's been added to our libraries over here. Now since we are working with Maven, you might be wondering that why didn't I add that in our POM dot XML? for some unknown reason, this h2 jar when it is downloaded from Maven repository, somehow it does not work.
So I have tested that you can also go ahead and give it a try. But it doesn't work. You come back and add this as the reference that I've shown. Since you are going to work with hibernate. We have to add the hibernate jars as dependencies. So I I'm going to open the pom dot XML.
Go to the pom dot XML tab here where I can actually edit the source code. I'm going to add a section here called dependencies. And inside the dependencies, I have to add a hibernate dependency. To do so let's go to the browser and go to MV and repository.com and search for hibernate. And the very first one says hibernate core here from our dot hibernate, this is what we want. I click on the hibernate core here.
And I would like to select the latest version which is five dot four dot one final. I go there and click on this section to copy that dependency. Come back to my Maven paste it and then save it as soon as I save it. You should see that it downloads the necessary JAR files from the internet. If you already have downloaded like in my case, it has done quickly. So you can see that under Maven dependencies, I have all the jars that are required for hibernate five application