zoukankan      html  css  js  c++  java
  • Spring Error : No unique bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined

    报错信息:

    Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public final void org.mybatis.spring.support.SqlSessionDaoSupport.setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 2...
     

    原因:

    beans.xml 中定义了两个 SqlSessionFactory bean,而在 SqlSessionDaoSupport 中调用了下面 setSqlSessionFactory(),造成了不唯一。
     
    1 @Autowired(required = false)
    2   public final void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
    3     if (! this.externalSqlSession ) {
    4       this. sqlSession = new SqlSessionTemplate(sqlSessionFactory);
    5     }
    6   }
     

    解决方案:

    修改 beans.xml 中与 SqlSessionFactory bean 相关的配置。

     
     
  • 相关阅读:
    node.js之npm命令安装扩展模块
    jquery选择器(转)
    node.js入门
    node.js之模块
    redhat 下装redis
    html 5之websocket(转)
    node.js安装和环境搭建
    javascript 动态加载脚本库
    HTML5 LocalStorage 本地存储
    【ecmascript】 ECMAScript 6概览【转】
  • 原文地址:https://www.cnblogs.com/huangzejun/p/8143927.html
Copyright © 2011-2022 走看看