记录springboot项目启动失败required a single bean, but 2 were found

转载:记录springboot项目启动失败required a single bean, but 2 were found—5180it的个人博客

转载:记录springboot项目启动失败required a single bean, but 2 were found—5180it的个人博客

我在搭建springboot项目时,启动包如下的错误

***************************

APPLICATION FAILED TO START

***************************

Description:

Field userService in com.king.framework.web.service.UserDetailsServiceImpl required a single bean, but 2 were found:

 - sysUserServiceImpl: defined in file [D:\workspace\self\king-spring-cloud\kingSpringSecurity\target\classes\com\king\system\service\impl\SysUserServiceImpl.class]

 - ISysUserService: defined in file [D:\workspace\self\king-spring-cloud\kingSpringSecurity\target\classes\com\king\system\service\ISysUserService.class]

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


项目启动发现有两个重复的bean,但实际上是service只有一个接口和一个实现类
网上说 @Primary 和@Qualifier 解决但是总不能把每一个service 都加一个注解吧。
那我现在不是出现相同bean
原来我在@MapperScan扫描的时候,扫描了包括service接口和实现类的包,改成下面就可以了

@MapperScan("com.king.**.mapper")

转载:http://www.513class.com/bbs/admin/1/117378.html

转载:http://www.513school.com/bbs/admin/1/117378.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值