idea 整合Swagger2

首先添加依赖

2.7.0

    io.springfox
    springfox-swagger2
    ${swagger.version}


    io.springfox
    springfox-swagger-ui
    ${swagger.version}

编写配置类

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.springcloud.springcloud.com.springcloud.web"))
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        .title("SpringBoot整合Swagger")
                        .description("SpringBoot整合Swagger,详细信息......")
                        .version("9.0")
                        .contact(new Contact("hjb","","[email protected]"))
                        .license("The Apache License")
                        .licenseUrl("http://www.baidu.com")
                        .build());
    }
}

idea 整合Swagger2_第1张图片

注意自己controller的文件的路径,根据实际情况修改

idea 整合Swagger2_第2张图片

 

 

参考路径:https://blog.csdn.net/xiaojin21cen/article/details/78654652

你可能感兴趣的:(idea 整合Swagger2)