首页 > 解决方案 > springfox.documentation.builders.RequestHandlerSelectors.withClassAnnotation

问题描述

我把spring swagger版本升级到3.0.0,但是启动项目显示这个错误:

2021-06-24 11:50:18.923  INFO 1 --- [           main] o.e.jetty.server.handler.ContextHandler  : Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext@2a666c8e{application,/,[file:///tmp/jetty-docbase.3371038441115428463.11004/, jar:file:/root/soa-room-service-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/springfox-swagger-ui-2.7.0.jar!/META-INF/resources],UNAVAILABLE}
2021-06-24 11:50:18.957  INFO 1 --- [           main] ConditionEvaluationReportLoggingListener : 
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-06-24 11:50:18.966 ERROR 1 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
    com.sportswin.soa.misc.config.swagger.SwaggerConfig.createRestApi(SwaggerConfig.java:86)
The following method did not exist:
    springfox.documentation.builders.RequestHandlerSelectors.withClassAnnotation(Ljava/lang/Class;)Lcom/google/common/base/Predicate;
The method's class, springfox.documentation.builders.RequestHandlerSelectors, is available from the following locations:
    jar:file:/root/soa-room-service-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/springfox-core-3.0.0.jar!/springfox/documentation/builders/RequestHandlerSelectors.class
It was loaded from the following location:
    jar:file:/root/soa-room-service-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/springfox-core-3.0.0.jar!/

我的春季启动版本是:2.1.12.RELEASE。春云版:Greenwich.SR1. 我应该怎么做才能解决这个问题?似乎没有人遇到这个问题。这是我的配置:

resolutionStrategy {
            eachDependency { DependencyResolveDetails details ->
                if (details.requested.group == 'io.springfox' && details.requested.name == 'springfox-swagger2') {
                    details.useVersion "3.0.0"
                }
                
            }
        }

标签: javaswaggerspringfox

解决方案


推荐阅读