swagger: fetching resource list: http://localhost:8080/template/v2/api-docs?group=springboot-templat

 引入的swagger版本:


    io.springfox
    springfox-swagger2
    2.7.0


    io.springfox
    springfox-swagger-ui
    2.7.0

引入的springboot版本:


    
        
            org.springframework.boot
            spring-boot-starter-parent
            2.0.4.RELEASE
            pom
            import
        
    

引入的springframework版本:

5.0.1.RELEASE

swagger配置:

@Configuration
// @EnableWebMvc //NOTE: Only needed in a non-springboot application
@EnableSwagger2
@ComponentScan("com.solin.template.web")
public class SwaggerAPIPluginConfig {
    @Bean //Don't forget the @bean annotation
    public Docket customImplementation() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("springboot-template").forCodeGeneration(true).pathMapping("/")
                .select().paths(paths()).build()
                .apiInfo(apiInfo()).useDefaultResponseMessages(false);
    }

    private Predicate paths(){
        return Predicates.and(PathSelectors.regex("/app/.*"), Predicates.not(PathSelectors.regex("/error")));
    }
    private ApiInfo apiInfo() {
        Contact contact = new Contact("admin", "", "");
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("springboot template API接口")//大标题
                .description("REST风格API")//小标题
                .contact(contact)//作者
                .termsOfServiceUrl("")
                .version("0.1")//版本
                .license("主页")//链接显示文字
                .licenseUrl("")//网站链接
                .build();
        return apiInfo;
    }
}

运行后,一直提示:fetching resource list: http://localhost:8080/template/v2/api-docs?group=springboot-templat

swagger: fetching resource list: http://localhost:8080/template/v2/api-docs?group=springboot-templat_第1张图片

确认配置无误,最后检查是springframework版本问题,改成 5.0.8.RELEASE 后正常显示

swagger: fetching resource list: http://localhost:8080/template/v2/api-docs?group=springboot-templat_第2张图片

所以出现类似问题,检查下spring的版本,因为swagger框架代码中会使用spring,可能版本问题会导致出现问题。 

你可能感兴趣的:(Springboot)