Java spring-mvc 和 hibernate 的好项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9831304/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 08:19:14  来源:igfitidea点击:

Good project with spring-mvc and hibernate

javaspringhibernatespring-mvc

提问by Vlad Lubenskiy

Please advise me a project where I can see how to use Spring MVC and Hibernate together in the right way. I'm new to these frameworks.

请告诉我一个项目,在那里我可以看到如何以正确的方式一起使用 Spring MVC 和 Hibernate。我是这些框架的新手。

采纳答案by JasonG

Appfuse has a Maven archetype for this stack. Strongly suggest you have a peak. Alternatively the book Spring in Action was a great resource for me in learning spring and hibernate/spring interaction - use Annotation driven transaction management as well and you have a really great start.

Appfuse 为该堆栈提供了一个 Maven 原型。强烈建议你有一个高峰。或者,Spring in Action 一书对我来说是学习 spring 和 hibernate/spring 交互的一个很好的资源 - 也使用注释驱动的事务管理,你有一个非常好的开始。

see here: http://appfuse.org/display/APF/Using+Spring+MVCappfuse-basic-spring is the basic project archetype.

见这里:http://appfuse.org/display/APF/Using+Spring+MVC appfuse-basic-spring 是基本的项目原型。

Using maven modules is a better practice. ie) appfuse-modular-spring

使用 Maven 模块是更好的做法。即)appfuse-modular-spring

If you install m2e (maven 2 eclipse plugin) creating a new maven project will allow you to select the archetype.

如果您安装 m2e(maven 2 eclipse 插件),则创建新的 maven 项目将允许您选择原型。

better answer:

更好的答案:

If I was going to recommend HOW to learn these technologies, I would say learn how to build a hibernate/maven/xml project first by following this: http://www.mkyong.com/hibernate/quick-start-maven-hibernate-mysql-example/

如果我要推荐如何学习这些技术,我会说首先学习如何构建一个 hibernate/maven/xml 项目:http: //www.mkyong.com/hibernate/quick-start-maven-hibernate -mysql-例子/

Then learn how to use spring for dependency injection with maven/hibernate and xml: http://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/Take special note of layering of the bo/dao pattern and how you use interfaces but wire in implementations with spring di - this is crucial for writing quality code

然后学习如何使用 spring 进行 maven/hibernate 和 xml 的依赖注入: http://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/ 特别注意 bo/dao 模式的分层和如何使用接口但如何使用 spring di 在实现中连接 - 这对于编写高质量代码至关重要

Next check hibernate annotations and annotation driven transactions: http://www.springbyexample.org/examples/hibernate-transaction-annotation-config.htmlhttp://www.springbyexample.org/examples/hibernate-transaction-annotation-config-code-example.html http://www.mkyong.com/hibernate/maven-hibernate-annonation-mysql-example/

接下来检查休眠注释和注释驱动的事务:http: //www.springbyexample.org/examples/hibernate-transaction-annotation-config.htmlhttp://www.springbyexample.org/examples/hibernate-transaction-annotation-config-代码示例.html http://www.mkyong.com/hibernate/maven-hibernate-annonation-mysql-example/

Finally, you can learn your mvc framework of choice. I actually recommend struts2 but it won't matter much. use spring DI by implementing interfaces and wiring implementations at runtime for you actions/controller. If you don't understand this how, you will after the hibernate/spring tutorials. Spring in action will be a good reference to keep on your desk but will take a few weeks to digest as you learn. Good luck! You can do it - I did and am now working as a java dev!

最后,您可以学习您选择的 mvc 框架。我实际上推荐 struts2 但这并不重要。通过在运行时为您的动作/控制器实现接口和接线实现来使用 spring DI。如果你不明白这是怎么回事,你会在 hibernate/spring 教程之后。Spring in action 将是一个很好的参考,可以放在你的办公桌上,但在你学习的过程中需要几周时间来消化。祝你好运!你可以做到——我做到了,现在是一名 Java 开发人员!

回答by Bozho

  • the petclinic appincludes these, and many more things
  • spring-roocan create a skeleton project using these technologies for you.

回答by richarbernal

If you are new to Spring MVC and Hibernate, I advice you to follow the Spring MVC step by step guide. The only problem with this is the version, the guide uses version 2.5 and the current release is 3.1.x, but it's a very good starting point to accumulate knowledge.

如果您是 Spring MVC 和 Hibernate 的新手,我建议您遵循Spring MVC step by step guide。唯一的问题是版本,指南使用2.5版本,当前版本是3.1.x,但这是一个很好的积累知识的起点。

回答by AzizSM

Spring MVC quickstart archetypeprovide simple spring-mvc and hibernate configuration.

Spring MVC 快速入门原型提供简单的 spring-mvc 和 hibernate 配置。