Spring @bean冲突解决方案
发布日期:2021-06-30 19:00:21 浏览次数:3 分类:技术文章

本文共 642 字,大约阅读时间需要 2 分钟。

引用2个jar都实现了相同的@bean注入,这个是feign的Level

@Beanpublic Level feignLoggerLevel() {        return Level.FULL;}

这样报错:

escription:xxx required a single bean, but 2 were found:        - feignLoggerLevel: defined by method 'feignLoggerLevel' in class path resource [com/xxx.class]        - logger: defined by method 'logger' in class path resource [com/yyy.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    @ConditionalOnMissingBean(Logger.Level.class)    public Level feignLoggerLevel() {        return Level.FULL;}

 

转载地址:https://linuxstyle.blog.csdn.net/article/details/114756122 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:不写容易出错的代码
下一篇:编程容易犯的错

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月16日 13时01分07秒