请告诉我一个项目,我可以在其中看到如何以正确的方式一起使用 Spring MVC 和 Hibernate。我是这些框架的新手。
最佳答案
Appfuse 有一个适用于此堆栈的 Maven 原型(prototype)。 强烈建议你有一个高峰。 或者,Spring in Action 一书对我来说是学习 spring 和 hibernate/spring 交互的重要资源 - 也使用注解驱动的事务管理,你有一个非常好的开始。
请看这里:http://appfuse.org/display/APF/Using+Spring+MVC appfuse-basic-spring 是基本的项目原型(prototype)。
使用 maven 模块是更好的做法。 IE) appfuse-modular-spring
如果您安装 m2e(maven 2 eclipse 插件)创建一个新的 maven 项目将允许您选择原型(prototype)。
更好的答案:
如果我要推荐如何学习这些技术,我会说首先按照以下步骤学习如何构建 hibernate/maven/xml 项目: http://www.mkyong.com/hibernate/quick-start-maven-hibernate-mysql-example/
然后学习如何使用spring与maven/hibernate和xml进行依赖注入(inject): http://www.mkyong.com/spring/maven-spring-hibernate-mysql-example/ 特别注意 bo/dao 模式的分层以及如何使用接口(interface),但使用 spring di 连接实现 - 这对于编写高质量代码至关重要
接下来检查hibernate annotations和annotation driven transactions: http://www.springbyexample.org/examples/hibernate-transaction-annotation-config.html http://www.springbyexample.org/examples/hibernate-transaction-annotation-config-code-example.html http://www.mkyong.com/hibernate/maven-hibernate-annonation-mysql-example/
最后,您可以学习您选择的 mvc 框架。我实际上推荐struts2,但这无关紧要。通过在运行时为您的操作/ Controller 实现接口(interface)和接线实现来使用 spring DI。如果你不明白这是怎么回事,你会在 hibernate/spring 教程之后。 Spring in action 将是一个很好的引用资料,可以放在你的办公 table 上,但在你学习的过程中需要几周的时间来消化。祝你好运!你可以做到 - 我做到了,现在正在作为一名 Java 开发人员工作!
关于java - spring-mvc 和 hibernate 的好项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9831304/