项目场景:
整合springboot项目并对springboot项目进行版本升级
问题描述:
错误信息:
Description:
Parameter 0 of method linkDiscoverers in org.springframework.hateoas.config.HateoasConfiguration required a single bean, but 15 were found:
- modelBuilderPluginRegistry: defined in null
- modelPropertyBuilderPluginRegistry: defined in null
- typeNameProviderPluginRegistry: defined in null
- documentationPluginRegistry: defined in null
- apiListingBuilderPluginRegistry: defined in null
- operationBuilderPluginRegistry: defined in null
- parameterBuilderPluginRegistry: defined in null
- expandedParameterBuilderPluginRegistry: defined in null
- resourceGroupingStrategyRegistry: defined in null
- operationModelsProviderPluginRegistry: defined in null
- defaultsProviderPluginRegistry: defined in null
- pathDecoratorRegistry: defined in null
- relProviderPluginRegistry: defined by method 'relProviderPluginRegistry' in class path resource [org/springframework/hateoas/config/HateoasConfiguration.class]
- linkDiscovererRegistry: defined in null
- entityLinksPluginRegistry: defined by method 'entityLinksPluginRegistry' in class path resource [org/springframework/hateoas/config/WebMvcEntityLinksConfiguration.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
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标记为@Primary,更新消费者以接受多个bean,或者使用@Qualifier来标识应该消费的bean
通过查找资料是由于jar包冲突所引起的问题,通过搜索知道了是 hateoas 这个jar包,但是在pom文件中没有引用过这个jar,判断这个jar包是由其他jar包依赖引入的,但是又不知道具体的是哪一个jar包。
解决方案:
使用maven命令 mvn dependency:tree 查看jar包相互引用的关联关系,把输出的内容负责到文本工具中,然后搜索 hateoas 就能够知道是由哪个jar包依赖引入的,然后去除引用问题即可解决。
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
<exclusions>
<exclusion>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
</exclusion>
</exclusions>
</dependency>