ant
ant

Reputation: 22948

Using spring framework with maven instead of ant

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

Upvotes: 1

Views: 2303

Answers (3)

Romain Linsolas
Romain Linsolas

Reputation: 81627

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...

Upvotes: 1

Lombo
Lombo

Reputation: 12235

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.

Upvotes: 1

Related Questions