zoukankan      html  css  js  c++  java
  • 使用swagger管理接口

    swagger 配置
    1.pom 增加jar包依赖
    <dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.4.0</version>
    </dependency>
    <dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.4.0</version>
    </dependency>
    2.MVC config 增加 <mvc:default-servlet-handler/>
    在resource下面的mvc-config.xml

    3.新建一个swagger类
    @EnableWebMvc
    @ComponentScan(basePackages={"com.mosai.vliveshow.api.app.interfaces.controller"})
    @Configuration
    @EnableSwagger2
    public class Swagger2 extends WebMvcConfigurationSupport{

    @Bean
    public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
    .apiInfo(apiInfo())
    .select()
    .apis(RequestHandlerSelectors.basePackage("com.mosai.vliveshow.api.app.interfaces.controller"))
    .paths(PathSelectors.any())
    .build();
    }

    private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
    .title("Spring Boot中使用Swagger2构建RESTful APIs")
    .description("更多Spring Boot相关文章请关注:http://blog.didispace.com/")
    .termsOfServiceUrl("http://blog.didispace.com/")
    .contact("程序猿DD")
    .version("1.0")
    .build();
    }

    }
    4.修改待扫描的路径
    5.配置服务器
    6.swagger UI的地址http://localhost:8080/vliveshow-api-app/swagger-ui.html#/

  • 相关阅读:
    列表
    *
    Model/View
    文件
    提示用户输入并获得输入
    编码
    使用静态QT库编译的程序不显示中文
    rm命令
    高阶函数
    jquery checkbox 操作
  • 原文地址:https://www.cnblogs.com/jier888/p/6410322.html
Copyright © 2011-2022 走看看