Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring MVC sample web app

I'm looking for an example Spring MVC 2.5 web app that I can easily:

  • Setup as a project in Eclipse
  • Deploy to a local app server (using Ant/Maven)

There are a couple of example applications included with the Spring distribution ('petclinic' and 'jpetstore'), but they don't provide any Eclipse project files (or a way to generate them). They also seem a bit complicated for my needs, e.g. require a local database to be setup.

like image 376
Dónal Avatar asked Apr 22 '09 15:04

Dónal


People also ask

What is Spring MVC with example?

A Spring MVC is a Java framework which is used to build web applications. It follows the Model-View-Controller design pattern. It implements all the basic features of a core spring framework like Inversion of Control, Dependency Injection.

What is Spring Web MVC?

The Spring Web MVC framework provides Model-View-Controller (MVC) architecture and ready components that can be used to develop flexible and loosely coupled web applications.


5 Answers

The easiest way to get up and running with a Spring MVC project is to use SpringSource Tool Suite, which is another free IDE based on Eclipse.

The integration between the IDE and Spring/Maven is tight, and it comes with an application server already setup for you to deploy your web app.

Follow these steps to get a working Spring MVC web app.

  1. To setup a new project in STS: Click File -> New -> Spring Template Project -> Spring MVC Project
  2. To pull in dependencies and compile your project: Right click your new project -> Run As -> Maven install
  3. To run your project inside an application server: Right click your new project -> Run As -> Run on Server -> SpringSource tc Server

If it works, you'll see a web page saying "Congratulations! You're running Spring!"

like image 148
Drew Avatar answered Oct 12 '22 01:10

Drew


While not specifically an app you can download, Developing a Spring Framework MVC application step-by-step covers creating a spring application in Eclipse with an ant build script, complete with unit tests.

This meets the following requirements:

  • Spring MVC 2.5
  • Project in Eclipse
  • Deploy to a local app server using Ant
  • Uses HSQL (no need to install a local DB)
like image 25
Zack The Human Avatar answered Oct 12 '22 01:10

Zack The Human


There's a Maven archetype (template project structure) for Spring MVC here:

http://docs.codehaus.org/display/MAVENUSER/Archetypes+List

That's a good starting place for this kind of investigation. To create an archetype using Maven, first install Maven:

http://maven.apache.org/plugins/maven-install-plugin/

and then create a project using the archetype:

http://maven.apache.org/guides/introduction/introduction-to-archetypes.html

You can also use the m2eclipse plugin for Eclipse to simplify this and it takes you through the stages of the project using a wizard. Just right click -> New Project -> Other, Maven and select the archetype. Hope that helps.

like image 28
Jon Avatar answered Oct 12 '22 01:10

Jon


Just spotted http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/ which could be interessting for you.

like image 29
resmo Avatar answered Oct 12 '22 02:10

resmo


To generate Eclipse project files: Use mvn eclipse:eclipse before importing the project into your workspace. This will create all required configuration files and hook your project up with all the required dependencies.

The mvc-basic and mvc-ajax sample projects in spring-samples (SVN URL: https://src.springframework.org/svn/spring-samples) are simple projects that do not need any local database support.

like image 43
Jatin Avatar answered Oct 12 '22 01:10

Jatin