• 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/

  • 相关阅读:
    springboot集成kafka
    elasticsearch http 搜索 测试
    linux下安装Elasticsearch
    laravel_admin 使用
    laravel 数据操作
    Win10+apache+PHP+Mysql
    laravel 坑(一)
    下载CentOS镜像
    window10 家庭版 添加Hyper-V虚拟机
    Win10 Composer 下载安装
  • 原文地址:https://www.cnblogs.com/ooo0/p/14389772.html
Copyright © 2020-2023  润新知