【发布时间】:2020-06-05 16:53:03
【问题描述】:
我已将 springfox 升级到 2.7.0(和 2.9.2)版本:
<springfox.version>2.7.0</springfox.version>
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>${springfox.version}</version>
</dependency>
并尝试启动应用程序时出现下一个错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名为“documentationPluginsBootstrapper”的 bean 时出错 在 URL 中定义 [jar:file:.....jar!/lib/springfox-spring-web-2.7.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: 通过构造函数参数表达的不满足的依赖关系 [java.util.List] 类型的索引 1:使用名称创建 bean 时出错 URL 中定义的“basePathAwareServicesProvider” [jar:file:/........!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class ]: bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]: 未找到默认构造函数;嵌套异常是 java.lang.NoSuchMethodException: springfox.documentation.spring.data.rest.BasePathAwareServicesProvider.(); 嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建在 URL 中定义的名称为“basePathAwareServicesProvider”的 bean [jar:文件:............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]: bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]: 未找到默认构造函数;嵌套异常是 java.lang.NoSuchMethodException: springfox.documentation.spring.data.rest。 BasePathAwareServicesProvider。初始化()
未找到默认构造函数; BasePathAwareServicesProvider。初始化()
为了避免 swaggers-ui.html 出现一些错误,我已经对这些类进行了注释:
@Configuration
@Profile("swaggerEnabled")
@EnableSwagger2
@EnableWebMvc
@Import(SpringDataRestConfiguration.class)
public class SwaggerConfiguration {
Springboot 应用程序:
@EnableSwagger2
@EnableWebMvc
@SpringBootApplication
@Import(value = {
......class,})
@Order(Ordered.HIGHEST_PRECEDENCE)
@ComponentScan(basePackages = {"....."})
public class PlatformApiApplication {
我尝试了一些来自 github 的解决方案,但没有任何效果。有人可以帮助我吗?谢谢。
【问题讨论】:
标签: java spring-boot swagger springfox