Java Spring 3 Web MVC 入门 - 设置一切
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2260552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting started with Spring 3 Web MVC - Setting everything up
提问by Matthew
I'm trying to get started with JAVA/Eclipse/Spring MVC but can't seem to find a "dummies" or "step-by-step" guide for setting everything up and creating the simplest proof-of-concept application.
我正在尝试开始使用 JAVA/Eclipse/Spring MVC,但似乎找不到用于设置所有内容和创建最简单的概念验证应用程序的“傻瓜”或“分步”指南。
I found http://static.springsource.org/docs/...-step-by-step/but there seem to be differences between Spring 2.5 and Spring 3 so i'm looking for something for Spring 3.
我找到了http://static.springsource.org/docs/...-step-by-step/但 Spring 2.5 和 Spring 3 之间似乎存在差异,所以我正在寻找 Spring 3 的东西。
Also, the tutorial for Spring 2.5 focuses on building the application usign Ant - This i will certainly be doing for releasing but when working within Eclipse i want to have set up the project so that i can use breakpoints/debugging and this is not covered at all.
此外,Spring 2.5 的教程侧重于使用 Ant 构建应用程序 - 我肯定会为发布而这样做,但是在 Eclipse 中工作时,我想设置项目以便我可以使用断点/调试,这在全部。
I've downloaded Eclipse, Tomcat and the Spring 3 Framework but that's about it and within the downloaded Spring Framework documentation it states:
我已经下载了 Eclipse、Tomcat 和 Spring 3 Framework,但仅此而已,并且在下载的 Spring Framework 文档中,它指出:
2.3 New getting started tutorial
There is now a new getting started tutorial for developing a basic Spring 3.0 MVC web application. This tutorial is a separate document that can be found at the Spring Documentation page
2.3 新的入门教程
现在有一个用于开发基本 Spring 3.0 MVC Web 应用程序的新入门教程。本教程是一个单独的文档,可以在Spring 文档页面找到
However, i can't seem to find such a tutorial on the linked page. My main problem at the moment, as seems to be the case for many people trying to get started with Spring, is that i can't seem to get everything set up.
但是,我似乎无法在链接页面上找到这样的教程。我目前的主要问题,似乎是许多尝试开始使用 Spring 的人的情况,是我似乎无法设置所有内容。
I've got a copy of Expert Spring MVC and Web Flowand i've also found this tutorialbut i don't know if the setups they describe are still relevant and whether they will allow debugging.
我有一份专家 Spring MVC 和 Web Flow的副本,我也找到了这个教程,但我不知道他们描述的设置是否仍然相关以及他们是否允许调试。
Can anyone please give some direction?
任何人都可以请给一些方向吗?
Thanks
谢谢
回答by Pascal Thivent
Get the mvc-basicor the petcaresample apps from the Spring Samples SVN repository. These samples have been updated to Spring 3.0 and are directly importable & runnable with SpringSource Tool Suite.
从Spring Samples SVN 存储库获取mvc-basic或petcare示例应用程序。这些示例已更新到 Spring 3.0,并且可以直接导入和使用SpringSource Tool Suite运行。
回答by Hans Westerbeek
These days, I think the easiest way to find out how to set up a spring application is by trying out Spring Roo. It may not be what you finally end up using when coding your project but it shows you exactly how to setup a Spring MVC web app.
现在,我认为了解如何设置 Spring 应用程序的最简单方法是尝试Spring Roo。它可能不是您在编码项目时最终使用的内容,但它向您展示了如何设置 Spring MVC Web 应用程序。
回答by Dhrumil Shah
I am also started to learn Spring 3.0 and i am not getting any help means any tutorials. but i find this site http://viralpatel.net/blogs/2010/06/spring-3-mvc-create-hello-world-application-spring-3-mvc.htmland its very help full for start up development. but still i am finding another example so that i come to know more about it if anybody knows some example in spring 3.0 then please provide me.
我也开始学习 Spring 3.0,我没有得到任何帮助意味着任何教程。但我发现这个网站http://viralpatel.net/blogs/2010/06/spring-3-mvc-create-hello-world-application-spring-3-mvc.html并且它对启动开发非常有帮助。但我仍然在寻找另一个例子,以便我对它有更多的了解,如果有人知道 spring 3.0 中的一些例子,请提供我。
Thanks Dhrumil Shah
感谢德鲁米尔沙阿
回答by Jeff C
回答by felicia
I've also been looking all over for a full Spring MVC 3.0 tutorial with Eclipse that I could follow and haven't had too much luck in my research. The closest and most helpful example that I could find is here: http://krams915.blogspot.com/2011/01/spring-mvc-3-hibernate-annotations.html. This is also a maven project, but I was able to move some things around in my Dynamic Web Project within Eclipse and at least get the initial page to come up. Currently, I'm having issues with spring finding my controller class, but I think that's a part of changing the configuration files to meet my project needs. But try it and I hope it works for you!
我还一直在寻找一个完整的 Spring MVC 3.0 Eclipse 教程,我可以遵循它,但在我的研究中没有太多运气。我能找到的最接近和最有用的例子在这里:http: //krams915.blogspot.com/2011/01/spring-mvc-3-hibernate-annotations.html。这也是一个 Maven 项目,但我能够在 Eclipse 中的动态 Web 项目中移动一些东西,至少可以显示初始页面。目前,我在 spring 查找控制器类时遇到了问题,但我认为这是更改配置文件以满足我的项目需求的一部分。但是尝试一下,我希望它对你有用!
回答by Christopher Armstrong
I found these tutorials really helpful:
我发现这些教程真的很有帮助:
http://krams915.blogspot.ch/p/tutorials.html
http://krams915.blogspot.ch/p/tutorials.html
I wanted to use REST and MongoDB and followed following tutorial with success:
我想使用 REST 和 MongoDB 并成功遵循以下教程:
http://krams915.blogspot.ch/2012/01/spring-mvc-31-implement-crud-with_4739.html
http://krams915.blogspot.ch/2012/01/spring-mvc-31-implement-crud-with_4739.html
I hope it helps. I know how you feel :) Had the same issues. But it's worth sticking with Spring and learning it. It's a great framework once you know it.
我希望它有帮助。我知道你的感受:) 有同样的问题。但值得坚持使用 Spring 并学习它。一旦你了解它,它就是一个很棒的框架。
Personally I made not so good experiences using Spring Roo. It can help you maybe a little bit for investigation how to setup a project but if you are new to Aspect Oriented Development you'll have a hard time figuring out what Spring Roo does. It can help you to setup a project really fast and easy but if you don't understand what's behind the facade it's hard working with it. This is not really for a beginner and no necessity for any project. But Aspect Oriented Development is worth wile learning and can be very useful to avoid boiler plate code.
就我个人而言,使用 Spring Roo 的体验并不是很好。它可以帮助您调查如何设置项目,但如果您不熟悉面向方面的开发,您将很难弄清楚 Spring Roo 是做什么的。它可以帮助您快速轻松地设置项目,但如果您不了解外观背后的内容,则很难使用它。这不是真正适合初学者,也不需要任何项目。但是面向方面的开发值得学习,并且对于避免样板代码非常有用。
回答by Vikas
There is a major difference in Spring 2.5 and Spring 3.x, Spring 3 or later introduces Annotations based bean wiring and dependency injection. The nice step by step tutorial i found is http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial
Spring 2.5 和 Spring 3.x 有一个主要区别,Spring 3 或更高版本引入了基于注解的 bean 连接和依赖注入。我发现的很好的分步教程是http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial