版本升级版本> 2.6.1时出现严重错误-NoSuchMethodException:BasePathAwareServicesProvider。<init>()

时间:2020-06-05 16:53:03

标签: java spring-boot swagger springfox

我已将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: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。初始化()

未找到默认构造函数; 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上的一些解决方案,但没有任何效果。有人可以帮我吗?谢谢。

1 个答案:

答案 0 :(得分:0)

删除行:

@Import(SpringDataRestConfiguration.class)

错误消失