`

浏览器报:org.springframework.beans.factory.NoSuchBeanDefinitionException

阅读更多
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:360)
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:686)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:219)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:149)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:541)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:223)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.lookupSessionFactory(OpenSessionInViewFilter.java:207)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:146)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
com.tlt.app.filter.SessionFilter.doFilter(SessionFilter.java:45)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)

它说 No bean named 'sessionFactory' is defined,想起了web.xml下有个配置:
<filter>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

把它去掉就可以了。
因为我没有让Spring管理hibernate,也就是说Spring配置文件中没有任何hibernate的影子,所以在web.xml中也不需要OpenSessionInViewFilter这个东西。否则就报错。

OpenSessionInViewFilter类作用 见下面的文章:
http://gundumw100.iteye.com/blog/508658
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics