zoukankan      html  css  js  c++  java
  • SpringBoot集成Swagger-Bootstrap-UI

    添加Maven依赖

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
        <groupId>com.github.xiaoymin</groupId>
        <artifactId>swagger-bootstrap-ui</artifactId>
        <version>1.9.6</version>
    </dependency>

    添加配置类

    @Configuration
    @EnableSwagger2
    @EnableSwaggerBootstrapUI
    public class SwaggerBootstrapConfig {
    
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.xc.xcspringboot.controller"))
                    .paths(PathSelectors.any())
                    .build();
        }
    
        private ApiInfo apiInfo() {
            return new ApiInfoBuilder()
                    .title("swagger-bootstrap-ui RESTful APIs")
                    .description("swagger-bootstrap-ui")
                    // .termsOfServiceUrl("http://localhost:5050/")
                    .contact("developer@mail.com")
                    .version("1.0")
                    .build();
        }
    }

    启动项目

    启动项目,访问地址:
    http://ip:port/doc.html 即可

    该开源项目GitHub地址:

    https://github.com/xiaoymin/Swagger-Bootstrap-UI

    该开源项目中文文档地址:

    https://doc.xiaominfo.com/

  • 相关阅读:
    css动画特效
    http标码集合
    vue的搭建项目
    多功能
    react官方脚手架搭建项目
    深入挖掘分析Go代码
    GoLang AST简介
    GoLang中的逃逸分析简介
    使用Golang实现状态机
    GoLang中的Context
  • 原文地址:https://www.cnblogs.com/ooo0/p/14389772.html
Copyright © 2011-2022 走看看