hibernate+spring整合步驟

hibernate+spring整合步驟

ID:40554923

大小:46.00 KB

頁數(shù):4頁

時間:2019-08-04

hibernate+spring整合步驟_第1頁
hibernate+spring整合步驟_第2頁
hibernate+spring整合步驟_第3頁
hibernate+spring整合步驟_第4頁
資源描述:

《hibernate+spring整合步驟》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在教育資源-天天文庫。

1、一,新建一個web工程,添加hibernate的支持(要選擇copy方式來引入jar包,不要用映射方式的,而且要注意不要創(chuàng)建hibernate的sessionFactory的類)二,隨即添加spring的支持(要選擇copy方式來引入jar包,不要用映射方式的,在選擇的時候選擇五個jar包,前面三個,和web和mis)三,偷梁換柱,把asm2.2.3的這個包刪掉,buildpath-->configbuildpath-->removeasm2.2.3,刪掉這里面的之后,還要刪除lib包下面的jar包四,把log4j屬性文件放置src目錄下面五,先對數(shù)據(jù)庫的表反轉(zhuǎn)生成pojo類和

2、DAO的方法,然后把dao層的方法移到dao層,然后建立service的包和action的包六,配置hibernate.cfg.xml中的一些配置項(要使用連接池要手工的導入c3p0的包)trueorg.hibernate.connection.C3P0ConnectionProviderorg.hibernate.cache.OSC

3、acheProviderupdate七,寫一個測試的方法得到一張表的所有內(nèi)容,到頁面顯示action中的內(nèi)容:action是要交個springMVC-servlet.xml里面來注冊的@Controller@RequestMapping("/article.do")publicclassArticleAction{@ResourceprivatePersonServicepersonService;@RequestMapping(params="method=getAllArt

4、icles")publicvoidgetAllArticles(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{ListarticlesList=personService.getArticlesList();request.setAttribute("list",articlesList);request.getRequestDispatcher("/myjsp.jsp").forward(request,response);}

5、}七,把applicationContext.xml中的頭子換掉,然后在里面配置事務管理

6、bernate3.HibernateTransactionManager">