美文网首页
Swagger2文档

Swagger2文档

作者: 荒天帝886 | 来源:发表于2019-10-12 15:37 被阅读0次

详细使用教程

依赖

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.8.0</version>
</dependency>

配置类

@Configuration
@EnableSwagger2
public class SwaggerConfig
{
    public Docket createApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.miao.springbootswagger"))
                .paths(PathSelectors.any())
                .build();
    }

    // 创建api的基本信息
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("springBoot 整合 Swagger2 实例")
                .description("更多技术内容分享见博客:https://blog.csdn.net/qq_24871519")
                .termsOfServiceUrl("https://blog.csdn.net/qq_24871519")
                .version("1.0")
                .build();
    }
}

相关文章

网友评论

      本文标题:Swagger2文档

      本文链接:https://www.haomeiwen.com/subject/vmwqmctx.html