Springfox Swagger 'Whitelabel Error Page' :com.google.common.base.Predicate cannot be resolved

假如想象 提交于 2019-12-11 07:06:22

问题


I am trying to use the swagger-ui for the rest services. I have a swaggerconfig class as follows.

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api(){
         return new Docket(DocumentationType.SWAGGER_2)                                            
                  .apiInfo(apiInfo())
                  .select()
                  .paths(PathSelectors.regex("\\.*"))
                  .build();                 
    }

    @SuppressWarnings("deprecation")
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Spring REST Sample with Swagger")
                .description("Spring REST Sample with Swagger")
                .termsOfServiceUrl(Open")
                .contact("Niklas Heidloff")
                .license("Apache License Version 2.0")
                .licenseUrl("https://github.com/LICENSE")
                .version("2.0")
                .build();
    }       
}

Its throws me an error on this line

.paths(PathSelectors.regex("\\.*"))

Which says

 The type com.google.common.base.Predicate cannot be resolved. It is indirectly referenced from required .class files

My question is: Isn't this lib included in the swagger base package. Also, none of the examples point towards adding it explicitly.


回答1:


Me too! Guava could be included by Swagger.

I solved removing com.google.guava from my .m2 folder, following a mvn clean & mvn install.

Likely in my local repo, guava jar was corrupted.



来源:https://stackoverflow.com/questions/46581571/springfox-swagger-whitelabel-error-page-com-google-common-base-predicate-cann

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!