19

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.

4

9 回答 9

15

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!"

于 2010-03-15T02:48:20.103 回答
9

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)
于 2009-04-22T16:04:51.223 回答
4

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.

于 2009-04-22T16:13:59.360 回答
3

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

于 2010-07-26T08:32:22.183 回答
2

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.

于 2010-07-25T23:22:52.983 回答
1

Use AppFuse

于 2009-04-22T16:06:00.940 回答
1

I got it working just as Drew described, but there is a trap for new users (meaning fresh install, no familiarity with Maven or m2eclipse). You'll get this error:

[ERROR] Error executing Maven.
[ERROR] The specified user settings file does not exist: /home/user/.m2/settings.xml

And the work around is to just make an almost empty settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
</settings>

(I later found this bug report.) After that, I was in business. I was even able to export as a WAR file and deploy onto my installation of WebSphere Community Edition. Thank you, Drew!


A little less earlier, I wrote:

Hmph. Never mind. I gave up, shut down my machine, and when I came back, everything worked (except for a minor Maven issue I'm working on). Chalk it up to a bug.


Earlier, I wrote:

I was very excited to hear about STS, so I downloaded and installed it. It went perfectly. This is a new machine, so I have the latest of everything - java 1.6, eclipse 3.5.1, etc.

On step 2 of the above instructions, I get this error: "The specified JRE installation does not exist"

I've set paths everywhere I can find, so I'm not sure which JRE it's complaining about. Help?

于 2010-04-23T20:26:55.370 回答
1

You could also use Spring Roo to do this. http://www.springsource.org/roo

于 2010-06-17T05:50:59.840 回答
0

You can use below link to download hello world spring mvc project

Spring MVC hello world example

于 2018-07-28T18:12:57.023 回答