user1883212
user1883212

Reputation: 7859

SpringMVC and Hibernate using Maven

I want to create an application using SpringMVC and Hibernate. I haven't found in Maven an archetype that allow me to have both.

I found this archetype with SpringMVC - but there is no Hibernate:

springmvc-archetype

I found this archetype with both Spring and Hibernate - But it's not MVC:

graniteds-spring-jpa-hibernate

So, my idea is to use "springmvc-archetype" and then add Hibernate later, as a dependency.

But I don't know if this is the right way.

What procedure do you suggest me to follow?

Upvotes: 0

Views: 1321

Answers (4)

qingmu
qingmu

Reputation: 482

When you create an application by using Spring MVC, Hibernate, you should add dependency as follows:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${springVersion}</version>
</dependency>

<!-- hibernate-->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>${hibernateVersion}</version>
</dependency>

After adding the dependency, your application can run.

When you want to determine whether a dependency exists, you can also visit MAVEN

Upvotes: 0

wSchmidt
wSchmidt

Reputation: 100

I also answered the other post you have going.

If you would rather go in the direction of generating the archetype from maven and then adding Spring MVC support, I'd suggest trying this very detailed tutorial:

http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/

In the above example, the 'maven-archetype-webapp' template is used to generate a generic Web Application Project. In turn the author then details how to convert the Maven web project to support Eclipse IDE. Once it is imported into Eclipse, he walks you through adding Spring-MVC support.

Upvotes: 1

Paolof76
Paolof76

Reputation: 919

You're right, there isn't an archetype that contains Spring, Spring MVC and Hibernate.

There are lots of tutorial out there to create a Spring/SpringMVC/Hibernate project, for example this: http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/

He chooses the other way around, first Spring-hibernate and then the MVC framework. It's a matter of how you thing is better for you. If you are new of these things, the first time you can follow the tutorial and when something goes wrong ask here.

Upvotes: 1

sevensevens
sevensevens

Reputation: 1750

I think it would be easier to start with a basic Spring archtype, and add Hibernate dependencies + config to that. Spring and Hibernate are two different open-source projects, and it doesn't surprise me a spring + hibernate archtype is a bit dated.

I'd start with this guide to using maven with spring and add in a hibernate dependency.

Upvotes: 0

Related Questions