• 七、集成swagger2


    1、添加依赖

    <!-- swager2 -->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>2.2.2</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>2.2.2</version>
            </dependency>

    2、添加配置

    package com.biniu.config;
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import springfox.documentation.builders.ApiInfoBuilder;
    import springfox.documentation.builders.PathSelectors;
    import springfox.documentation.builders.RequestHandlerSelectors;
    import springfox.documentation.service.ApiInfo;
    import springfox.documentation.spi.DocumentationType;
    import springfox.documentation.spring.web.plugins.Docket;
    import springfox.documentation.swagger2.annotations.EnableSwagger2;
    
    /**
     * swagger2配置
     * @author lay
     * @date 2018/4/15.
     * @time 15:58
     */
    @Configuration
    @EnableSwagger2
    public class Swagger2 {
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.biniu.controller"))
                    .paths(PathSelectors.any())
                    .build();
        }
    
        private ApiInfo apiInfo() {
            return new ApiInfoBuilder()
                    .title("springboot中使用swagger2创建apis")
                    .version("v1.0")
                    .build();
        }
    }
  • 相关阅读:
    PHP(表单元素)
    PHP(一般标签介绍,标签特性,实体名称,绝对路径与相对路径)
    Oracle课程档案,第十七天
    Oracle课程档案,第十六天
    Oracle课程档案,第十四天
    Oracle课程档案,第十五天
    Oracle课程档案,第十三天
    Oracle课程档案,第十二天
    Oracle课程档案。第十一天
    [haoi2011]防线修建
  • 原文地址:https://www.cnblogs.com/lay2017/p/8847973.html
Copyright © 2020-2023  润新知