报错信息:

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

 
 

Spring Error : No unique bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined的更多相关文章

  1. 出错:Failed to convert property value of type 'org.apache.ibatis.session.defaults.DefaultSqlSessionFactory' to required type 'java.lang.String' for property 'sqlSessionFactoryBeanName';

    出错的详细信息: 3 ERROR [http-nio-80-exec-3] org.springframework.web.servlet.DispatcherServlet - Context in ...

  2. No unique bean of type [net.shougongfang.action.paymoney.AlipayPayMoneyReturnObj] is defined: Unsat

    0 你把@Service放到实现类上吧.这个问题好像不止一个人在问啦 2013年10月25日 10:34 shidan66  30  0 1 1 加入评论 00 1,@service放到实现上  2. ...

  3. paip . 解决spring No unique bean of type [com.mijie.homi.search.service.index.MoodUserIndexService]

    paip . 解决spring No unique bean of type   [com.mijie.homi.search.service.index.MoodUserIndexService] ...

  4. spring exception--No unique bean of type

    今天碰到一个问题,就是我现有项目需要加一个定时器任务,我的代码如下: <!-- 每日数据同步 总数监测任务******************begin --> <bean id=& ...

  5. Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined

    Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined stac ...

  6. ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.

    在做多表映射查询时,在同一个resultMap中写了1:1映射和1:n映射,结果测试时报错如下: org.apache.ibatis.exceptions.PersistenceException: ...

  7. The error may exist in com/bjpowernode/dao/StudentDao.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderExcept

    The error may exist in com/bjpowernode/dao/StudentDao.xml### Cause: org.apache.ibatis.builder.Builde ...

  8. Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined(转)

    最近项目里面,用了spring的定时任务,一直以来,项目运行的不错.定时器也能正常使用.可是,今天启动项目测试的时候,盯着启动Log看了一阵子,突然间发现,启动的Log中居然有一个异常,虽然一闪而过, ...

  9. spring eureka required a bean of type 'com.netflix.discovery.DiscoveryClient' that could not be found.

    spring在集成第三方过程很容易出现类名相同,且基本作用相同的类.这样给初学者带来一定的困惑. 导致用错类而出现以下问题. required a bean of type 'com.netflix. ...

随机推荐

  1. Oracle11g静默安装dbca,netca报错处理--直接跟换操作系统

    最近给一个客户安装oracle 11gr2 概述: 操作系统:linux 32位操作系统 [oracle@nbsrfx response]$ uname -aLinux nbsrfx 2.6.32-5 ...

  2. Django框架中的model(操作数据库)

    什么是ORM ORM,即Object-Relational Mapping(对象关系映射),它的作用是在关系型数据库和业务实体对象之间作一个映射,这样,我们在具体的操作业务对象的时候,就不需要再去和复 ...

  3. gitup问题的处理

    在使用本地建立git仓库后,准备使用 因为之前已经登录了,所以没有给登录的命令行 1.git init         命令初始化仓库 2.git add .     命令将所有的文件传输到git仓库 ...

  4. 缓存与ABP Redis Cache

    缓存与ABP Redis Cache 为什么要用缓存 为什么要用缓存呢,说缓存之前先说使用缓存的优点. 减少寄宿服务器的往返调用(round-trips). 如果缓存在客户端或是代理,将减少对服务器的 ...

  5. 将DLL文件直接封装进exe执行文件中(C#)

    前言:由于项目需要,需制作一个注册机,将个人PC的MAC值和硬盘序列号与软件进行绑定,由于笔者的C++不是很好,所以采用C#进行开发.但在采用C#的时候,获取硬盘的MAC值和序列号的时候又不是很准确, ...

  6. java设计模式—多工厂模式

    概念           多个工厂模式,是对普通工厂方法的改进,在普通工厂模式中,如果字符串传递出错,则不能正   确创建对象,而多个工厂模式是提供多个工厂方法,分别创建对象.     多个工厂模式关 ...

  7. js比较日期大小

    第一种方法: var starttime = "2007-1-2 7:30"; var endtime = "2007-2-31 8:30"; alert(Co ...

  8. poj 2905 双向队列(待补充)

    Parallel Computer Simulator   Description Programs executed concurrently on a uniprocessor system ap ...

  9. javaweb学习总结(七)——HttpServletResponse对象(一)(转)

    转载自 http://www.cnblogs.com/xdp-gacl/p/3789624.html Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对 ...

  10. iOS 读书笔记-国际化

    吐槽一下:国际化-我想说学习的这个project好痛苦. 也许是百度的原因,总是不能找到自己想要东西. 找到的内容不是不具体就是时间有点久了.让我这种小白非常头痛. 以下记录一下整个过程. 国际化是什 ...