Field in required a single bean, but 2 were found:
我在其他类注入的时候出现以下错误
@Autowired
NodeAgentService nodeAgentService;
异常
Description:
Field mibService in com.xxx.xxx.controller.SnmpController required a single bean, but 2 were found:
- mibServiceImpl: defined in file [F:\xxxx\monitorcenter\target\classes\com\xxx\xxx\service\impl\MibServiceImpl.class]
- nodeAgentServiceImpl: defined in file [F:\xxxx\monitorcenter\target\classes\com\xxx\xxx\service\impl\NodeAgentServiceImpl.class]
解决方法:在mibService实现类添加注解
@Primary
springboot环境下遇到这个问题,解决方案参考来源:https://stackoverflow.com/questions/46343560/class-required-a-single-bean-but-2-were-found
public interface OIDService {
}
@Slf4j
@Service
public class OIDServiceImpl implements OIDService {
}
public interface MibService extends OIDService{
}
@Service
@Slf4j
@Primary
public class MibServiceImpl extends OIDServiceImpl implements MibService
{}
public interface NodeAgentService extends MibService{
}
@Service
@Slf4j
public class NodeAgentServiceImpl extends MibServiceImpl implements NodeAgentService {
}
Field in required a single bean, but 2 were found:的更多相关文章
- Field amqpTemplate in * required a single bean, but 3 were found:
Field amqpTemplate in * required a single bean, but 3 were found: Spring Boot 启动的时候报的错 使用Spring Boot ...
- 【记录】Field required a single bean, but 2 were found:
重构遇到个小问题,记录下: 错误信息: *************************** APPLICATION FAILED TO START ************************ ...
- Field baseMapper in com.baomidou.mybatisplus.extension.service.impl.ServiceImpl required a single bean, but xx were found:
在学习使用 mybatis-plus 时,遇到一个奇怪的异常 如 代码一: 代码一: Error starting ApplicationContext. To display the conditi ...
- @Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法
@Autowired注解是spring用来支持依赖注入的核心利器之一,但是我们或多或少都会遇到required a single bean, but 2 were found(2可能是其他数字)的问题 ...
- Parameter 0 of method sqlSessionTemplate in org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration required a single bean, but 2 were found:
Parameter 0 of method orderSqlSessionFactory in com.config.MultipleDBConfig required a single bean, ...
- springboot多数据源启动报错:required a single bean, but 6 were found:
技术群: 816227112 参考:https://stackoverflow.com/questions/43455869/could-not-autowire-there-is-more-than ...
- Spring多个数据源问题:DataSourceAutoConfiguration required a single bean, but * were found
原因: @EnableAutoConfiguration 这个注解会把配置文件号中的数据源全部都自动注入,不会默认注入一个,当使用其他数据源时再调用另外的数据源. 解决方法: 1.注释掉这个注解 2. ...
- TClientDataSet 提交时提示 Field value Required 但是未提示具体哪个字段。
TClientDataSet 提交时提示 Field value Required 但是未提示具体哪个字段. 这个错误特别麻烦,要使用 midas 控件时,虽然很方便.但是出错了根本找不到原因,特别是 ...
- springboot jpa mongodb 整合mysql Field in required a bean of type that could not be found Failed to load ApplicationContext
1.完整报错 *************************** APPLICATION FAILED TO START *************************** Descripti ...
随机推荐
- java中有个很强大的工具jconsole.exe
这个工具可以监控java程序的线程,cpu和内存使用情况.
- java线程基础巩固---Daemon线程的创建以及使用场景分析
daemon线程既守护线程,而在jdk中对于Thread中针对守护线程有专门的API,如下: 而之前在公司项目中就看到过有人使用过Thread中的这个API,但是对于它的使用场景完全不知,所以这次好好 ...
- 实际应用脚本备份1——Ubuntu下应用升级脚本与执行方法
程序自动更新脚本,命名为makefile: build:run run: killall java /webapps/‘应用目录名’/ /webapps/ ‘应用目录名’/ cd /opt/apach ...
- Linux用户影子文件——shadow
Linux使用不可逆的加密算法(如MD5,SHA1等)来加密口令.和/etc/passwd类似,/etc/shadow文件中每条记录用冒号“:”分隔,形成9个域,格式如下所示: username:pa ...
- 安装WIN10+Ubuntu18.04安装教程(实测有效)
转载原文链接:https://www.cnblogs.com/masbay/articles/10745170.html 安装过程中尤其注意分区时候的挂载点一定要选对!!!选择Ubuntu的EFI所在 ...
- (四) 结构化查询语言SQL——2
3)ORDER BY排序语句 通常,查询的结果是以无序的方式显示的,有时需要将查询结果按照一定次序来进行排序.ORDER BY就可以用上了,例如查询课程号为202的课程成绩的所有信息,并按照成绩降序排 ...
- timestamp和datetime
datetime数据类型在MySQL之前占8个字节,5.6之后占5个字节,datetime的范围1000-01-01 00:00:00------9999-12-31 23:59:59,格式采用YYY ...
- Python之文字转图片
Pygame模块一览表: 引入pygame模块 ,若本机没有请自行pip install pygame #载入必要的模块 import pygame #pygame初始化 pygame.init() ...
- CSS 定位详解
CSS 有两个最重要的基本属性,前端开发必须掌握:display 和 position position 属性的作用 position属性用来指定一个元素在网页上的位置,一共有5种定位方式,即posi ...
- .net大文件上传断点续传解决方案
HTML部分 <%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="index.aspx. ...