jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Maven Archetypes, eclipse and hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Maven Archetypes, eclipse and hibernate" Watch "Maven Archetypes, eclipse and hibernate" New topic

Maven Archetypes, eclipse and hibernate

Adam Johansson

Joined: May 31, 2011
Posts: 3


I've decided it was time for me to learn how to use databases with java.
Hibernate seemed to be very useful although I get somewhat stuck when trying to
add the necessary dependencies. I'm trying to follow this tutorial:


which tells me that if I use MyEclipse, I only need to right-click to project to get the hibernate capabilities.
I only have regular eclipse though...

So, I thought using maven I could easily get everything i need, alas i only find archetypes like
hibernate-validator and hibernate-search which doesn't seem to
be what I'm looking for. I also tried adding dependencies manually through maven
(Right-click project -> Maven -> Add Dependency) but I seem to find packages with the same name but different
groupID, leaving me utterly confused as to which for example antlr package to add.

Perhaps leaning eclipse and maven separately is a better idea than to start directly with hibernate?
(Although I would actually want to start with hibernate+wicket).
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15041

Welcome to the Ranch!

Yes, I think learning Eclipse and Maven and Hibernate at the same time can be a bit daunting. I think it would be best to first learn a bit about Maven, just running it from the command line, and when you understand that try to use it from an IDE such as Eclipse.

I used to be reluctant to use Maven because I worried that I'd lose track of the dependencies of my project myself, but after using it for a while I think it's very convenient. To use Maven, you setup your project with a standard directory structure, and you create a file named pom.xml that contains information about your project: the project name, version etc. and its dependencies. When you run Maven to build your project, it will automatically download the necessary libraries and compile your code with them. Note that you don't really need to use the specific archetype for a project that uses Hibernate; you can also just generate a simple Java project and add the Hibernate dependency yourself in pom.xml. An archetype is just a template for a project with some specific dependencies etc. already set up, but you can just as well add those dependencies yourself if there's no archetype that already includes them.

See this Maven in 5 minutes tutorial for a hands-on introduction.

If you don't have MyEclipse, you can get the m2eclipse plug-in for regular Eclipse to get Maven support in Eclipse.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Adam Johansson

Joined: May 31, 2011
Posts: 3

Thank you Jesper!

I will follow your advice!
It is sorta covered in the JavaRanch Style Guide.
subject: Maven Archetypes, eclipse and hibernate
jQuery in Action, 3rd edition