标签:nbsp 异常 sum The spring UI 接口 one red
如果同一个接口有多个bean实现类,spring在运行时会出现如下异常
required a single bean, but 2 were found:
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
@Primary的意思是在众多相同的bean中,优先使用用@Primary注解的bean.而@Qualifier这个注解则指定某个bean有没有资格进行注入。
@Component
@Primary
@Autowired
@Component
@Qualifier("fjaoidfj")
@Autowired
@Qualifier("fjaoidfj")
标签:nbsp 异常 sum The spring UI 接口 one red
原文地址:https://www.cnblogs.com/yangfei-beijing/p/9208300.html