springfox

swagger-bootstrap-ui是国内的一个swagger开源项目,从发起到现在已经有三年了。
初次体验了一下,觉得还是挺不错的,就如当初使用mybatis-plus那样,因为有了mybatis的基础,所以过渡到mybatis-plus很没有压力。
现在由swagger2到swagger-bootstrap-ui也是没有压力的,基本上参考官方文档就能弄好了。

目前我应用在我个人的博客项目上,效果如图:

关于如何搭建步骤,我主要是参考官方文档,我本次写的就作为官方文档的一点补充:

一、添加Maven依赖

1<dependency> 2 <groupId>com.github.xiaoymin</groupId> 3 <artifactId>swagger-bootstrap-ui</artifactId> 4 <version>1.9.3</version> 5</dependency> 6 7 <dependency> 8 <groupId>io.springfox</groupId> 9 <artifactId>springfox-swagger2</artifactId> 10 <version>2.9.2</version> 11</dependency>

二、编写配置类

1import org.springframework.context.annotation.Bean; 2import org.springframework.context.annotation.Configuration; 3import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI; 4import springfox.documentation.builders.ApiInfoBuilder; 5import springfox.documentation.builders.PathSelectors; 6import springfox.documentation.builders.RequestHandlerSelectors; 7import springfox.documentation.service.ApiInfo; 8import springfox.documentation.spi.DocumentationType; 9import springfox.documentation.spring.web.plugins.Docket; 10import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 12@Configuration 13@EnableSwagger2 14@EnableSwaggerBootstrapUI 15public class SwaggerConfiguration { 16 17 @Bean 18 public Docket createRestApi() { 19 return new Docket(DocumentationType.SWAGGER_2) 20 .apiInfo(apiInfo()) 21 .select() 22 .apis(RequestHandlerSelectors.basePackage("com.blog.springboot")) 23 .paths(PathSelectors.any()) 24 .build(); 25 } 26 27 private ApiInfo apiInfo() { 28 return new ApiInfoBuilder() 29 .title("swagger-bootstrap-ui RESTful APIs") 30 .description("swagger-bootstrap-ui") 31 .termsOfServiceUrl("http://www.youcongtech.com") 32 .contact("developer@mail.com") 33 .version("1.1") 34 .build(); 35 } 36}

三、去下载对应的前端资源

下载地址为:https://github.com/xiaoymin/Swagger-Bootstrap-UI/tags ,如下图所示:

四、下载完毕后解压并将swagger-bootstrap-ui放到springboot项目职工的src/main/resources目录下

步骤如图:
找到这个文件夹

并将其迁移到springboot对应的目录

五、整个流程完成后,启动应用,访问地址为http://IP:Port//doc.html

参考资料如下:
swagger-bootstrap-ui文档:http://doc.xiaominfo.com

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )