views:

279

answers:

3

Is there a tutorial somewhere which shows how to use spring framework with maven instead of ant? This one seems very good but it's all built with ant.

EDIT

I really don't know which answer to accept both are valid. I'll wait for some time let the community decide

+1  A: 

If you already know maven, then you can quickly start working with spring using this archetype

appfuse-basic-spring

Note that it sets everything up for Spring MVC, Spring and Hibernate so you should remove unnecessary files. Still, it's a great start.

If you don't know much about maven templates check this URL that explains how to use archetypes. An archetype is basically a project template.

The complete list of templates can be found here.

Lombo
+1  A: 

Basically, the build.xml of the tutorial has 3 main targets :

  • build the application
  • deploy it on Tomcat server
  • Unit testing using a in-memory database (hsqldb)

Regarding the first point, you will just need to create a war project on Maven. As you told in your comment, you are already using Maven in anothers projects, so I don't think it will cause you lots of troubles. You will just need to add the Spring dependency:

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.2</version>
    </dependency>

The second part concerns the deployment on Tomcat. Just use the cargo plugin for that.

For the last point, you will just need to add the HSQLDB dependency in your pom.xml:

    <dependency>
        <groupId>hsqldb</groupId>
        <artifactId>hsqldb</artifactId>
        <version>1.8.0.7</version>
        <scope>test</scope>
    </dependency>

Then, you will have to instanciate the database in one of your JUnit test case...

romaintaz
+1  A: 

The Spring 3.0 samples are Maven based:

Pascal Thivent
The `pom.xml` in this project does not handle the auto-deployment on Tomcat. However, it manages the two other points, i.e. the build and the in-memory database unit testing.
romaintaz
@romaintaz Just use `mvn tomcat:run`, no need to setup cargo or anything.
Pascal Thivent