springBoot 配置SwaggerUi接口测试


1. 通过maven导入jar包


        
            io.springfox
            springfox-swagger2
            2.9.2
        

        
            io.springfox
            springfox-swagger-ui
            2.9.2
        

2. 编写SwaggerConfig配置文件

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tw.skynet.controller"))   //项目接口类路径
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        .title("API接口调试")
                        .description("详细信息")
                        .version("1.0")
                        .contact(new Contact(
                                "drgs",  //项目名称
                                "https://www.00.cn",  //备注网址
                                "11111111111@163.com"))  //备注邮箱地址
                        .license("The Apache License")
                        .licenseUrl("https://www.00.cn")
                        .build()
                );
    }
}

相关