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
-
原因:@Autowired注解注入时发现有多个实现类,而项目中并无多个实现类的情况,最终发现是由于Hateoas的新功能产生的
-
解决方案:在swagger配置文件中添加以下代码
@Primary @Bean public LinkDiscoverers discoverers() { List<LinkDiscoverer> plugins = new ArrayList<>(); plugins.add(new CollectionJsonLinkDiscoverer()); return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); }