springfox更新到3.0.0后,SwaggerConfig文件中guava的Predicates已经过时,如何解决?

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

这是我的 SwaggerConfig 文件。将 springfox 更新到 3.0.0

后,“com.google.common.base.Predicates”中使用的谓词已过时
@EnableSwagger2
@Configuration
public class SwaggerAutoConfig {

    @Value("${project.name}")
    String projectName;

    @Value("${project.description}")
    String projectDescription;

    @Value("${project.version}")
    String projectVersion;

    @ConditionalOnMissingBean(Docket.class)
    @Bean
    public Docket swaggerSetup() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build()
                .apiInfo(apiInfo())
                .tags(new Tag("Endpoint for faking the /islive and /isready /health
                                      info","Endpoint for faking the /islive and /isready /health
                                      info."));
    }

显然我尝试使用 java.util.function 中的 Predicate,它似乎工作正常。还有其他方法可以解决这个问题吗?

swagger guava predicate swagger-2.0 springfox
1个回答
0
投票

原因:guava和springfox之间的传递依赖

在转向 Swagger 3.0.0 之前,guava (com.google.guava) 是 springfox (io.springfox.swagger2) 中的传递依赖,它曾经包含 Predicates 方法

在新版本中,guava 已从 springfox 中删除。

解决方案:

可以在你的 pom.xml 文件中单独添加 guava 依赖

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