springmvc注入类 NoUniqueBeanDefinitionException: No qualifying bean of type [] is defined: expected single错误
在springmvc中注入服务时用@Service
当有两个实现类时都标明@Service后则会出现异常:
nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.james.dao.impl.BaseDao] is defined: expected single matching bean but found 2:
这是因为都标明了@Service会自动注入,这时会导致不清楚实际运行时实例化哪一类。
解决:
方法一
实际运用哪一个实现类就在哪个类上注入@Service,另外一个不标注
方法二
都不标注@Service,在resource文件夹中配置 applicationContext.xml,表明实际运行哪个实现类。
<bean id="serviceImpl" class="com.james.service.impl.ServiceImpl"></bean>
springmvc注入类 NoUniqueBeanDefinitionException: No qualifying bean of type [] is defined: expected single错误的更多相关文章
- 多个@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 ' ...
- Spring4.14 事务异常 NoUniqueBeanDefinitionException: No qualifying bean of type [....PlatformTransactionManager]
环境为Spring + Spring mvc + mybatis:其中Spring版本为4.1.4 spring配置文件: <?xml version="1.0" encod ...
- 【Spring】手动获取spring容器对象时,报no qualifying bean of type is defined
手动获取容器对象时,报no qualifying bean of type is defined, 经过调查,发现手动获取的时候,该类所在的包必须经过spring容器初始化. 1.SpringConf ...
- [zhuanzai]Bean对象注入失败 .NoSuchBeanDefinitionException: No qualifying bean of type..
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying b ...
- 关于SpringMVC未找到类[No qualifying bean of type [...]is defined]问题
首先,不要慌,出现这个问题肯定是某一个配置注解没写上.. 无非就几个地方: 1.控制层是否添加@Controller or 需要pring管理的类是否添加@Component 2.DAO层是否添加@R ...
- Spring Task Scheduler - No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
1. Overview In this article, we are discussing the Springorg.springframework.beans.factory.NoSuchBea ...
- spring注入时报错::No qualifying bean of type 'xxx.xxMapper'
做一个小项目,因为有 baseService,所以偷懒就没有写单独的每个xxService接口,直接写的xxServiceImpl,结果在service实现类中注入Mapper的时候,用的 @Auto ...
- 使用springmvc的时候报错NoSuchBeanDefinitionException: No qualifying bean of type
NoSuchBeanDefinitionException: No qualifying bean of type 其实我至今都不知道错误的根源在哪里,<context:component-sc ...
- NoSuchBeanDefinitionException:No qualifying bean of type found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
报错如下: NoSuchBeanDefinitionException:No qualifying bean of type found for dependency: expected at l ...
随机推荐
- gem install报错
[root@app-test ruby-2.2.3]# gem install capistrano -v 2.15 ERROR: While executing gem ... (Gem::Rem ...
- java 内部类 嵌套类
.markdown-body { color: #24292e; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI" ...
- Python爬虫(十三)_案例:使用XPath的爬虫
本篇是使用XPath的案例,更多内容请参考:Python学习指南 案例:使用XPath的爬虫 现在我们用XPath来做一个简单的爬虫,我们尝试爬取某个贴吧里的所有帖子且将该帖子里每个楼层发布的图片下载 ...
- 》》jqurey mobile 初
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta na ...
- 走进Linux01-磁盘分区与文件夹结构
近期学习Linux,首先安装系统,遇到了磁盘分区.之前仅仅知道Linux分区是从/(根文件夹)開始的,至于磁盘格式,多块盘怎样挂载全然不了解,系统的查询了一下Linux磁盘分区和文件夹结构,整理一下. ...
- libmemcached的安装及測试
1.安装memcached ~$ wget http://memcached.googlecode.com/files/memcached-1.2.8.tar.gz. $ tar xvzf lmemc ...
- Ansible@一个高效的配置管理工具--Ansible configure management--翻译(一)
未经书面许可,请勿转载 --- Ansible is the simplest way to automate apps and IT infrastructure 这是Ansible官方站 ...
- Java面向对象的特征
面向对象的特征 封装.继承.多态.(有人问第四个特征,再加抽象) 封装 体现形式(2种) 函数---提高代码的复用性 属性的私有化---将属性设置为私有的,通过提供对外的访问方法来间接操作对应属性,可 ...
- Centos7.4下用Docker-Compose部署WordPress
前言 最近在学习Docker相关知识,通过阅读第一本Docker书后,正想着手实战用一下这个技术,但又不太敢直接在项目环境下动手.考虑足足三秒钟之后决定买个阿里云ECS搭建一个属于自己的基于Docke ...
- iOS 实现UIImageView 的不停的旋转(更新:2017.7.26)
1.先创建一个UIImageView. - (void)createImageView { UIImageView *imageView = [[UIImageView alloc] initWith ...