SpringBoot中提示:Consider marking one of the beans as @Primary, updating the consumer to accept multipl

亦凉 2022-10-10 09:42 61阅读 0赞

场景

SpringBoot项目在启动时提示:

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

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JBREFPX0xJVU1BTkdfUUlaSEk_size_16_color_FFFFFF_t_70

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

加@Primary表示某个实现类首选注入

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0JBREFPX0xJVU1BTkdfUUlaSEk_size_16_color_FFFFFF_t_70 1

发表评论

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

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

相关阅读