简体   繁体   中英

Integrating Hibernate to Spring running on embedded jetty

I have just returned to Spring after 5 years of gap and it seems lot is changed. I have a task to create a REST Service using Spring with hibernate as an ORM, So far I am able to run a basic Rest Service using embedded jetty and able to make GET/POST calls, the next is to integrate hibernate into it so that the data fetch/Sent operation actually use MySQL instead of sending hard-coded response(which I have done currently).

The issue is earlier I used to work on Spring MVC using Tomcat where we had web.xml to define the dispatcher servlet and application-context which in turn were used to define hibernate config and other beans declaration, but now having embedded jetty I am not finding a way to integrate hibernate to my REST app, Is the way to add configuration is changed from XML to class based config. I searched over internet but maybe I am out of words or not using correct keywords, in short, Have no luck finding some solution to integrate hibernate to my Spring app which is using embedded jetty.

Could some please breif me about the recent changes or point me to the right tutorial ?

Any help appreciated, thanks in advance !

ps - I have used this example to progress so far https://github.com/pethoalpar/SpringMvcJettyExample

Yes , lot of changes in these 5 years and one of the game-changer is spring-boot

If you want to build a brand new project especially if you want to run the web application on the embedded container such as Jetty , you can check out spring-boot.It already provides integration with Jetty , hibernate and Spring MVC REST service.

The end result is that you just need to change a little bit configuration (most probably the DB connection info) and you can quickly get a production-ready REST service backed by JPA/Hibernate which can just run without any XML configuration anymore.

There are tons of tutorials in Internet talking about how to do it . You should easily find them out such as this using the keywords something likes "springboot webservice hibernate jetty" etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM