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使用策略模式代替if/else
平时在开发中避免不了使用大量的if else语句,但过多层的if else对于性能有很大的开销,类似如下代码 public class MainStart { public static void m ...
- PAT Basic 1044 火星数字 (20 分)
火星人是以 进制计数的: 地球人的 被火星人称为 tret. 地球人数字 到 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov ...
- sql 新增一个不为空的列
ALTER TABLE dbo.FW_PATROL_TASK ADD CRUISE_TYPE INT; UPDATE FW_PATROL_TASKSET CRUISE_TYPE = 0; --设置新列 ...
- moment.js 使用方法记录
操作 设值/赋值 1. 具体方法. 1)毫秒(millisecond) moment().millisecond(Number); moment().millisecond(); // Number ...
- 【icpc2019网络赛南昌站】Yukino With Subinterval
傻b错误调一天系列 原题: 大意:给你一个数列a,字词两种操作: 1.把c[l]改成r 2.询问在区间[l,r]中,有多少个极大子区间满足子区间里的数全部一样,且在[x,y]范围内 (对于满足条件的区 ...
- BZOJ 世界树
第一步首先建虚树 第二步两遍dfs,一次从叶子到根,一次从根到叶子,就可以得到虚树中每个节点在M个询问点中离他最近的是哪个(简称为控制点) 第三步考虑计算答案,对于整个树,我们把节点化为三个种类 1. ...
- vector引用参数
#include<iostream> #include<vector> using namespace std; //定义一个计算数字的函数,返回计算后的vector numb ...
- 2 APIView与序列化组件
1.入门 1.1 参考blog 官方文档:http://www.django-rest-framework.org/tutorial/quickstart/#quickstart yuan的Blog: ...
- 个人签发https证书
环境: jdk1.8 window7 cmder 1.生成证书库jks keytool.exe -genkeypair -alias www.bingco.com -keyalg RSA ^ -key ...
- Swoole:PHP7安装Swoole的步骤
下载 swoole 首先下载swoole的源码包,这个操作很简单,没有太多说的.(没有wget:brew install wget--mac) wget -c https://github.com/s ...