Swagger错误与版本升级版本> 2.6.1 - NoSuchMethodException: BasePathAwareServicesProvider.<init>()

问题描述 投票:0回答:1

我已经将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: 错误地创建了在URL[jar:file:......jar!libspringfox-spring-web-2.7.0.jar!springfoxdocumentationspringwebpluginsDocumentationPluginsBootstrapper.class]中定义的名称为 "documentationPluginsBootstrapper "的bean。 通过类型为[java.util.List]的构造函数参数表达的不满意的依赖关系。错误创建URL中定义了名称为'basePathAwareServicesProvider'的bean[jar:file:......!libspringfox-data-rest-2.7.0.jar!springfoxdocumentationspringdatarestBasePathAwareServicesProvider.class]。 Bean实例化失败;嵌套异常为org.springframework.beans.BeanInstantiationException。Failed to instantiate [springfox.document.spring.data.rest.BasePathAwareServicesProvider]: 没有找到默认的构造函数;嵌套异常是java.lang.NoSuchMethodException:springfox.document.spring.data.rest.BasePathAwareServicesProvider.();嵌套异常是org.springframework.beans.factory.BeanCreationException: 错误创建了URL[jar:file:......!libspringfox-data-rest-2.7.0.jar!springfoxdocumentationspringdatarestBasePathAwareServicesProvider.class]中定义的名称为'basePathAwareServicesProvider'的bean。 Bean实例化失败;嵌套异常为org.springframework.beans.BeanInstantiationException。Failed to instantiate [springfox.document.spring.data.rest.BasePathAwareServicesProvider]: 没有找到默认的构造函数;嵌套的异常是java.lang.NoSuchMethodException:springfox.document.spring.data.rest. BasePathAwareServicesProvider.init()

没有找到默认的构造函数; 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
1个回答
0
投票

删除该行。

@Import(SpringDataRestConfiguration.class)

错误消失了

© www.soinside.com 2019 - 2024. All rights reserved.