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 ...
随机推荐
- Kaggle_泰坦尼克乘客存活预测
转载 逻辑回归应用之Kaggle泰坦尼克之灾 此转载只为保存!!! ————————————————版权声明:本文为CSDN博主「寒小阳」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附 ...
- CF892E Envy[最小生成树]
题意:有一张 $n$ 个点$ m $条边的连通图.有$Q$ 次询问.每次询问给出 $k[i]$ 条边,问这些边能否同时出现在一棵最小生成树上.$n,m,Q,\sum k\le 500000$. 这题利 ...
- 使用python脚本进行数据清洗(1)
1. 原始表 CREATE TABLE ml_100k (userid INT, movieid INT, rating INT, unixtime STRING) ROW FORMAT DELIMI ...
- Python模拟浏览器多窗口切换
# 模拟浏览器多窗口切换 # 代码中引入selenium版本为:3.4.3 # 通过Chrom浏览器访问发起请求 # Chrom版本:59 ,chromdriver:2.3 # 需要对应版本的Chro ...
- #7 div2 B Layer Cake 造蛋糕 智商题+1
B - Layer Cake Time Limit:6000MS Memory Limit:524288KB 64bit IO Format:%I64d & %I64u Sub ...
- K8S中DaemonSet
DaemonSet DaemonSet 确保全部(或者一些)Node 上运行一个 Pod 的副本.当有 Node 加入集群时,也会为他们新增一个 Pod .当有 Node 从集群移除时,这些 Pod ...
- Centos 7禁止ftdi_sio模块
$ dmesg[ 3305.097301] usb 1-1: USB disconnect, device number 7[ 3306.883704] usb 1-1: new high-speed ...
- Selenium定位策略
1.通过XPath使用contains() 它将启动一个窗口,其中包含文本框开发中涉及的所有特定代码. 记下它的id属性. 通过XPath定位元素的语法 - 使用contains()可以写成: //& ...
- vue绑定样式
使用三目运算符绑定样式 本来以为使用vue模版写法,在绑定单个样式,也就是一个class类名的时候可以直接书写,就像这样 <div id="app"> <div ...
- springboot 2.2.0 SNAPSHOT 解决 repositories.repository.id must be unique 的问题
如果打包 jar 也报错了 ,那也是这个的原因,注释掉即可 <!-- 这个仓库必须注释掉 否则打包 war 的时候 , 会报错 'repositories.repository.id' must ...