Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or us

墨蓝 2023-06-28 11:10 104阅读 0赞

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

解决方法:

springboot启动报错如下:

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Disconnected from the target VM, address: ‘127.0.0.1:54176’, transport: ‘socket’

Process finished with exit code 1

因为sringboot通过@Autowired注入接口的实现类时发现有多个,也就是有多个类继承了这个接口,spring容器不知道使用哪一个。

第一种、加@Primary表示某个实现类首选注入:http://www.yayihouse.com/yayishuwu/chapter/2408

发表评论

表情:
评论列表 (有 0 条评论,104人围观)

还没有评论,来说两句吧...

相关阅读