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

 引入的swagger版本:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.7.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.7.0</version>
</dependency>

引入的springboot版本:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.4.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

引入的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<String> 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

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

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

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值