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 相关的配置。

     
     
  • 相关阅读:
    CSS(八) 常见的居中定位
    VUE常用的标签属性和指令
    ES6面向对象
    ES6解构赋值
    jvarScript的多个参数
    ES6的箭头函数
    Light OJ 1125 Divisible Group Sums
    Light OJ 1168 Wishing Snake
    Light OJ 1044 Palindrome Partitioning
    hdu 3967 Zero's Number
  • 原文地址:https://www.cnblogs.com/huangzejun/p/8143927.html
Copyright © 2011-2022 走看看