22
Nov
09

Spring MVC application using Archetypes


The following page describes the process of creating a simple spring MVC application using an archetype. The archetype was created my me for testing purposes. All it does is print a simple message to the browser when you navigate to the application.

Requirements

Maven

Access to the command prompt

The Maven page above talks about eclipse you don’t need eclipse to install and run the simple springMVC application described here.

Creating the Project

Execute the following archetype to create the spring MVC application

mvn archetype:generate -DarchetypeGroupId=com.vermatech \
-DarchetypeArtifactId=springmvc-archetype -DarchetypeVersion=1.0-SNAPSHOT \
-DarchetypeRepository=http://www.vermatech.com/m2repo

Answer some simple questions:

Define value for groupId: : com.test2
Define value for artifactId: : vtSpringTest
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  com.test2: :
Confirm properties configuration:
groupId: com.test2
artifactId: vtSpringTest
version: 1.0-SNAPSHOT
package: com.test2
 Y: :

Running the Application in Jetty

Execute the following in the project’s folder.

mvn jetty:run

Navigate to the following url http://localhost:8080/ and you should see a Welcome page come up.

Advanced Jetty Settings

The following allows jetty to serve from a different context root. It also allows the application to be reloaded 2 seconds after a change is detected to the classes or the web.xml file.

        <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                                <version>7.0.0.v20091005</version>
                <configuration>
                        <scanIntervalSeconds>2</scanIntervalSeconds>
                        <webAppConfig>
                                <contextPath>/biggerstrongerbetterfaster</contextPath>
                        </webAppConfig>
                </configuration>
        </plugin>

Thats All!

This site is a collaborative effort! The complete text and sourcecode for this is available on GitHub. Corrections and enhancements are welcome, please make the change and submit a pull request in the comment area below.
Advertisements

3 Responses to “Spring MVC application using Archetypes”


  1. 1 J Smith
    September 12, 2012 at 9:15 am

    this did not work: mvn archetype:generate -DarchetypeGroupId=com.vermatech \
    -DarchetypeArtifactId=springmvc-archetype -DarchetypeVersion=1.0-SNAPSHOT \
    -DarchetypeRepository=http://www.vermatech.com/m2repo

  2. 3 Tom Bray
    May 2, 2013 at 6:42 pm

    should be:

    mvn archetype:generate -DarchetypeGroupId=org.vtechfw -DarchetypeArtifactId=springmvc-archetype -DarchetypeVersion=1.0-SNAPSHOT -DarchetypeRepository=http://www.vermatech.com/m2repo


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 78 other followers

November 2009
S M T W T F S
« Oct   Dec »
1234567
891011121314
15161718192021
22232425262728
2930  

Blog Stats

  • 822,102 hits

%d bloggers like this: