升级Springboot版本异常:HateoasConfiguration required a single bean, but 3 were found

时间:2025-03-20 21:59:33

在项目从升级到2.2.1时,报错

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method linkDiscoverers in  required a single bean, but 3 were found:
	- relProviderPluginRegistry: defined by method 'relProviderPluginRegistry' in class path resource [org/springframework/hateoas/config/]
	- linkDiscovererRegistry: defined in null
	- entityLinksPluginRegistry: defined by method 'entityLinksPluginRegistry' in class path resource [org/springframework/hateoas/config/]


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

解决方法:

修改swagger版本

<dependency>
      <groupId></groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.6.1</version>
</dependency>

<dependency>
      <groupId></groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>2.6.1</version>
</dependency>