1. 程式人生 > >springMvc+mybatis事務管理不起作用解決

springMvc+mybatis事務管理不起作用解決

而由於伺服器啟動時的載入Spring相關配置檔案的順序為applicationContext.xml(Spring的配置檔案) ---> applicationContext-mvc.xml(SpringMVC的配置檔案),按照上面的配置Spring載入applicationContext.xml配置檔案時會載入@Controller註解標註的Controller元件,並且對其進行掃描裝配,但是此時的Service還沒有進行事務增強處理,得到的將是原樣的Service(沒有經過事務加強處理,故而沒有事務處理能力),所以我們應用在applicationContext.xml(Spring配置檔案)中不掃描Controller,而在applicationContext-mvc.xml(SpringMVC配置檔案)中不掃描Service。修改如下:
a.spring-context.xml配置檔案