Spring MVC 示例 Web 应用程序
我正在寻找一个示例 Spring MVC 2.5 Web 应用程序,我可以轻松地:
- 在 Eclipse 中设置为项目
- 部署到本地应用程序服务器(使用 Ant/Maven)
Spring 发行版中包含几个示例应用程序(“petclinic”) ' 和 'jpetstore'),但它们不提供任何 Eclipse 项目文件(或生成它们的方法)。 对于我的需求来说,它们似乎也有点复杂,例如需要设置本地数据库。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
启动和运行 Spring MVC 项目的最简单方法是使用 SpringSource 工具套件,这是另一个基于Eclipse的免费IDE。
IDE 和 Spring/Maven 之间的集成非常紧密,并且它附带了一个已设置的应用程序服务器,供您部署 Web 应用程序。
按照以下步骤获取可用的 Spring MVC Web 应用程序。
如果它有效,您将看到一个网页,显示“恭喜!您正在运行 Spring!”
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.
If it works, you'll see a web page saying "Congratulations! You're running Spring!"
虽然不是专门可以下载的应用程序,开发 Spring Framework MVC 应用程序步骤逐步涵盖使用 ant 构建脚本在 Eclipse 中创建 Spring 应用程序,并完成单元测试。
这满足以下要求:
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 的 Maven 原型(模板项目结构):
http://docs。 codehaus.org/display/MAVENUSER/Archetypes+List
这是此类调查的一个很好的起点。 要使用 Maven 创建原型,请首先安装 Maven:
http://maven.apache。 org/plugins/maven-install-plugin/
然后使用原型创建一个项目:
http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
您还可以使用 Eclipse 的 m2eclipse 插件来简化此操作,它会带您完成使用向导的项目阶段。 只需右键单击-> 新项目-> 其他,Maven并选择原型。 希望有帮助。
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.
刚刚发现 http://blog.springsource.com/2010 /07/22/spring-mvc-3-showcase/ 您可能会感兴趣。
Just spotted http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/ which could be interessting for you.
生成 Eclipse 项目文件:
在将项目导入工作区之前使用 mvn eclipse:eclipse。 这将创建所有必需的配置文件,并将您的项目与所有必需的依赖项挂钩。
spring-samples 中的 mvc-basic 和 mvc-ajax 示例项目(SVN URL: https:// src.springframework.org/svn/spring-samples)是不需要任何本地数据库支持的简单项目。
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.
使用AppFuse
Use AppFuse
我按照 Drew 的描述让它工作,但是对于新用户来说有一个陷阱(意味着全新安装,不熟悉 Maven 或 m2eclipse)。 你会得到这个错误:
解决方法就是制作一个几乎空的settings.xml:(
我后来发现此错误报告。)
之后我就开始做生意了。 我什至能够导出为 WAR 文件并部署到我安装的 WebSphere Community Edition 上。 谢谢你,德鲁!
稍早一点,我写道:
哼。 没关系。 我放弃了,关闭了我的机器,当我回来时,一切正常(除了我正在处理的一个小 Maven 问题)。 把它归结为一个错误。
早些时候,我写道:
我很高兴听到 STS,所以我下载并安装了它。 一切都很顺利。 这是一台新机器,所以我拥有最新的一切 - java 1.6、eclipse 3.5.1 等。
在上述说明的步骤 2 中,我收到此错误:
“指定的 JRE 安装不存在”
我已经在所有能找到的地方设置了路径,所以我不确定它抱怨的是哪个 JRE。 帮助?
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:
And the work around is to just make an almost empty settings.xml:
(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?
您也可以使用 Spring Roo 来执行此操作。 http://www.springsource.org/roo
You could also use Spring Roo to do this. http://www.springsource.org/roo
您可以使用下面的链接下载 hello world spring mvc 项目
Spring MVC hello world example
You can use below link to download hello world spring mvc project
Spring MVC hello world example