Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good project with spring-mvc and hibernate

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.

like image 354
Vladyslav Lubenskyi Avatar asked Mar 22 '12 22:03

Vladyslav Lubenskyi


2 Answers

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.

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

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

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

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/

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

Next check hibernate annotations and 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/

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!

like image 97
JasonG Avatar answered Oct 30 '22 22:10

JasonG


  • the petclinic app includes these, and many more things
  • spring-roo can create a skeleton project using these technologies for you.
like image 36
Bozho Avatar answered Oct 30 '22 22:10

Bozho