zoukankan      html  css  js  c++  java
  • [spring] org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is d .

    异常:

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined 
        (sessionFactory没有定义)
    

    在web.xml中配置OpenSessionInViewFilter时应该指定SessionFactory的名字,配置如下:

     

    <filter>  

          <filter-name>HibernateOpenSession</filter-name>   

         <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>  

         <init-param>  

           <param-name>sessionFactoryBeanName</param-name>  

          <param-value>mySessionFactory</param-value>

        </init-param>

    </filter>  

    Lazy问题可以通过加opensessioninviewfilter解决
    在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>*.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>openSessionInViewFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>

    [转载自:http://blog.csdn.net/zxl0016/article/details/7875485]

  • 相关阅读:
    svn命令
    Lambda 表达式
    JAVA 探究NIO
    JAVA I/O系统
    MySQL 锁
    spring boot 集成 zookeeper 搭建微服务架构
    架构演化
    JAVA 集合
    spring boot 发送邮件
    MySQL 隔离级别
  • 原文地址:https://www.cnblogs.com/kentyouyou/p/3146260.html
Copyright © 2011-2022 走看看