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

Swagger Error with version upgrading version > 2.6.1 - NoSuchMethodException: BasePathAwareServicesProvider.<init>()

我已经将 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: Error creating bean with name 'documentationPluginsBootstrapper' defined in URL [jar:file:.....jar!/lib/springfox-spring-web-2.7.0.jar!/springfox/documentation/spring/web/plugins/DocumentationPluginsBootstrapper.class]: Unsatisfied dependency expressed through constructor argument with index 1 of type [java.util.List]: Error creating bean with name 'basePathAwareServicesProvider' defined in URL [jar:file:/..............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]: No default constructor found; nested exception is java.lang.NoSuchMethodException: springfox.documentation.spring.data.rest.BasePathAwareServicesProvider.(); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'basePathAwareServicesProvider' defined in URL [jar:file:............!/lib/springfox-data-rest-2.7.0.jar!/springfox/documentation/spring/data/rest/BasePathAwareServicesProvider.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]: No default constructor found; nested exception is java.lang.NoSuchMethodException: springfox.documentation.spring.data.rest. BasePathAwareServicesProvider. init ()

未找到默认构造函数; BasePathAwareServicesProvider。 init()

我已经像这样注释了 类 以避免 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 的一些解决方案,但没有任何效果。有人可以帮我吗?谢谢。

删除行:

@Import(SpringDataRestConfiguration.class)

错误消失