No bean named 'sessionFactory' is defined
阿新 • • 發佈:2018-11-12
1.在擴大session作用範圍時幫助hibernate懶載入時,遇到sessionFactory沒有被定義的問題
<!-- 擴大session作用範圍 -->
<filter><filter-name>openSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
<param-name>sessionFactoryBeanName</param-name>
<param-value>SessionFactory</param-value>
</init-param> -->
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
解釋:顧名思義,就是sessionFactory沒有被找到,因為我們的applicationContext.xml中沒有配置相應名稱為sessionFactory的內容所以要麼
將你applicationContext.xml的sessionfactory名稱改成sessionFactory要麼重新指定名稱
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>SessionFactory</param-value>
</init-param>