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

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

image-20211124170227467

  • 原因:@Autowired注解注入时发现有多个实现类,而项目中并无多个实现类的情况,最终发现是由于Hateoas的新功能产生的

  • 解决方案:在swagger配置文件中添加以下代码

    @Primary
    @Bean
    public LinkDiscoverers discoverers() {
        List<LinkDiscoverer> plugins = new ArrayList<>();
        plugins.add(new CollectionJsonLinkDiscoverer());
        return new LinkDiscoverers(SimplePluginRegistry.create(plugins));
    }
    
posted @ 2021-11-24 17:08  江亭夕望  阅读(5455)  评论(0)    收藏  举报