集成测试开始失败,Spring boot 2.2.0 升级后,使用 Swagger 最新版本 2.9.2 和 HATEOS



集成测试在Swagger最新版本2.9.2&HATEOS

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'linkDiscoverers' 
defined in class path resource [org/springframework/hateoas/config/HateoasConfiguration.class]: 
Unsatisfied dependency expressed through method 'linkDiscoverers' parameter 0; 
nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException:
No qualifying bean of type 'org.springframework.plugin.core.PluginRegistry<org.springframework.hateoas.client.LinkDiscoverer,
org.springframework.http.MediaType>' available: expected single matching bean but 
found 3: relProviderPluginRegistry,linkDiscovererRegistry,entityLinksPluginRegistry
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: 
No qualifying bean of type 'org.springframework.plugin.core.PluginRegistry<org.springframework.hateoas.client.LinkDiscoverer, 
org.springframework.http.MediaType>' available: expected single matching bean but found 3: 
relProviderPluginRegistry,linkDiscovererRegistry,entityLinksPluginRegistry

springfox的问题可能需要一段时间才能解决,但最新的swagger v3也有类似于springfox 的功能

https://github.com/springdoc/springdoc-openapi.git

只禁用了SpringFox依赖项,添加了SpringDoc,并用SpringDoc bean替换了SpringFoxbean。一切都按预期进行。我所需要做的就是在每个rest服务上转换几个注释,以便SpringDoc正确地显示所有内容。SpringDoc确实有效

我使用了这个,它对我的有效

<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency

最新更新