org.springframework.beans.factory.NoUniqueBeanDefinitionException 导致原因之一
导致此异常原因很多,以下仅是针对其中一种因素的解决办法。
下面是DAO接口、Service接口、Service实现类的全路径名(全部定义在com.xxx.projetc包下)
com.xxx.projetc.MyDAO; com.xxx.projetc.MyService; com.xxx.projetc.MyServiceImpl;
spring-dao.xml配置片段如下
<bean id="" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
<property name="basePackage" value="com.xxx.projetc" />
</bean>
spring-service.xml配置片段如下
<!--扫描service包下所有使用注解的类型 -->
<context:component-scan base-package="com.xxx.projetc" />
由于MyDAO和MyServiceImpl全部定义在com.xxx.projetc包下,导致负责解析spring-dao.xml和spring-service.xml的相关spring框架程序重复对com.xxx.projetc进行了扫描。
解决此问题的方法是将MyDAO和MyServiceImpl分别放入不同的包,如下所示:
com.xxx.projetc.dao.MyDAO; com.xxx.projetc.service.MyService; com.xxx.projetc.service.impl.MyServiceImpl;
org.springframework.beans.factory.NoUniqueBeanDefinitionException 导致原因之一的更多相关文章
- 多个@bean无法通过@resource注入对应的bean(org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found )
一.异常 org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ' ...
- 升级版本后报这个异常 : org.springframework.beans.factory.NoUniqueBeanDefinitionException
今天写代码时出现上面这个异常,很是奇怪.从网上下载了个Spring源码包,通过追踪源码发现并没有到加载工程代码中去.于是分析和Spring包有关系. 查看依赖库发现有两个版本的Spring.通过分析去 ...
- Spring AOP:Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException
1 报错 Exception encountered during context initialization - cancelling refresh attempt: org.springfra ...
- 出现 org.springframework.beans.factory.BeanCreationException 异常的原因及解决方法
1 异常描述 在从 SVN 检出项目并配置完成后,启动 Tomcat 服务器,报出如下错误: 2 异常原因 通过观察上图中被标记出来的异常信息,咱们可以知道 org.springframework.b ...
- org.springframework.beans.factory.BeanDefinitionStoreException
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'd ...
- org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException
1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...
- springtest mapper注入失败问题解决 {@org.springframework.beans.factory.annotation.Autowired(required=true)}
花费了一下午都没有搜索到相关解决方案的原因,一是我使用的 UnsatisfiedDependencyException 这个比较上层的异常(在最前面)来进行搜索, 范围太广导致没有搜索到,而且即便是有 ...
- org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.my.service.ProductService] for bean with name 'productService' defi报错解决方法
原 javaweb项目报错org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [XXX] ...
- 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined
报错!!!!!!!!!!! 因用maven项目不是很熟练,经常在Maven转Web项目(为什么要转web项目?因为要在tomcat中跑起来.maven项目好像是可以直接部署到tomcat的,或集成to ...
随机推荐
- [Swift]LeetCode822. 翻转卡片游戏 | Card Flipping Game
On a table are N cards, with a positive integer printed on the front and back of each card (possibly ...
- Kubernetes---存储
pod中定义需要的存储卷,类型为pvc pvc 与 pv 建立绑定关系 kubectl explain pv 定义pv时不要加namspce
- Redis 设计与实现 (九)--Lua
EVAL script numkeys key [key ...] arg [arg ...] script: 你的lua脚本 numkeys: key的个数 key: ...
- restful风格的API
在说restful风格的API之前,我们要先了解什么是rest.什么是restful.最后才是restful风格的API! PS(REST:是一组架构约束条件和原则,REST是Roy Thomes F ...
- ECMAScript5.1的运算符、类型转换总结
一.运算符优先级 从高到低 运算符 说明 () 圆括号 . [] new(带参数列表) 字段访问.数组索引.new(带参数列表) () new(无参数列表) 函数调用,无参数列表 ++(后置递增) - ...
- redis 系列11 列表对象
一. 列表对象概述 Redis列表是简单的字符串列表,按照插入顺序排序.你可以添加一个元素到列表的头部(左边)或者尾部(右边).一个列表最多可以包含 232 - 1 个元素 (4294967295, ...
- Python爬虫入门教程 10-100 图虫网多线程爬取
图虫网-写在前面 经历了一顿噼里啪啦的操作之后,终于我把博客写到了第10篇,后面,慢慢的会涉及到更多的爬虫模块,有人问scrapy 啥时候开始用,这个我预计要在30篇以后了吧,后面的套路依旧慢节奏的, ...
- 从锅炉工到AI专家(6)
欠拟合和过拟合 几乎所有的复杂方程都存在结果跟预期差异的情况,越复杂的方程,这种情况就越严重.这里面通常都是算法造成的,当然也存在数据集的个体差异问题. 所以"欠拟合"和" ...
- 初识区块链——用JS构建你自己的区块链
前言 区块链太复杂,那我们就讲点简单的.用JS来构建你自己的区块链系统,寥寥几行代码就可以说明区块链的底层数据结构.POW挖矿思想和交易过程等.当然了,真实的场景远远远比这复杂.本文的目的仅限于让大家 ...
- Linux 进程管理工具 supervisord 安装及使用
Supervisor是用Python实现的一款非常实用的进程管理工具 1.安装过程非常简单 安装python 安装meld3-0.6.8.tar.gz 安装supervisor-3.0a12.tar. ...