在Spring Boot中使用swagger-bootstrap-ui
在Spring Boot中使用swagger-bootstrap-ui
swagger-bootstrap-ui是基于swagger接口api实现的一套UI,因swagger原生ui是上下结构的,在浏览接口时不是很清晰,所以,swagger-bootstrap-ui是基于左右菜单风格的方式,适用与我们在开发后台系统左右结构这种风格类似,方便与接口浏览
GitHub:https://github.com/xiaoymin/Swagger-Bootstrap-UI
欢迎大家Watch,Fork,Star
界面预览:


引入swagger
在pom.xml文件中引入swagger以及ui的jar包依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<!--引入ui包-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.7</version>
</dependency>
配置configuration
配置swagger的启用配置文件,关键注解@EnableSwagger2
一下配置是支持接口分组的配置,如果没有分组配置,只需要创建一个Docket即可
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("资源管理")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.baseinfo.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createMonitorRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("实时监测")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.monitor.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createActivitiRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("工作流引擎")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.activiti.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createBaseRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("kernel模块")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.kernel.ctl"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createComplaintRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("投诉管理")
.select()
.apis(RequestHandlerSelectors.basePackage("com.lishiots.dc.complaint.ctl"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("swagger RESTful APIs")
.description("swagger RESTful APIs")
.termsOfServiceUrl("http://www.test.com/")
.contact("xiaoymin@foxmail.com")
.version("1.0")
.build();
}
}
Controller层使用swagger注解
ctl代码层:
@Api(tags = "banner管理")
@RestController
@RequestMapping("/api/bannerInfo")
public class BannerCtl {
@Autowired
private BannerInfoService service;
@PostMapping("/query")
@ApiOperation(value = "查询banner",notes = "查询banner")
public Pagination<BannerInfo> bannerInfoQuery(){
Pagination<BannerInfo> pagination = service.bannerInfoQuery();
return pagination;
}
}
接口访问
在浏览器输入:http://${host}:${port}/doc.html
在Spring Boot中使用swagger-bootstrap-ui的更多相关文章
- Spring Boot中使用Swagger CodeGen生成REST client
文章目录 什么是Open API规范定义文件呢? 生成Rest Client 在Spring Boot中使用 API Client 配置 使用Maven plugin 在线生成API Spring B ...
- Spring Boot 中使用 Swagger
前后端分离开发,后端需要编写接⼝说明⽂档,会耗费⽐较多的时间. swagger 是⼀个⽤于⽣成服务器接⼝的规范性⽂档,并且能够对接⼝进⾏测试的⼯具. 作用 ⽣成接⼝说明⽂档 对接⼝进⾏测试 使用步骤 ...
- spring boot 中使用swagger 来自动生成接口文档
1.依赖包 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swa ...
- spring boot 中使用swagger
一.pom.xml <dependency> <groupId>io.springfox</groupId> <artifactId>springfox ...
- 【swagger】1.swagger提供开发者文档--简单集成到spring boot中【spring mvc】【spring boot】
swagger提供开发者文档 ======================================================== 作用:想使用swagger的同学,一定是想用它来做前后台 ...
- Spring Boot中使用Swagger2构建RESTful APIs介绍
1.添加相关依赖 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <depen ...
- 在spring Boot中使用swagger-bootstrap-ui(原文)
1.swagger简介 Swagger是一个API接口管理工具,支持在线测试接口数据,根据配置自动生成API文档,结合spring mvc而提供界面化方法文档的一个开源框架. 1.1Swagger主要 ...
- Spring Boot 快速整合Swagger
一.前言 Spring Boot作为当前最为流行的Java web开发脚手架,越来越多的开发者选择用其来构建企业级的RESTFul API接口.这些接口不但会服务于传统的web端(b/s),也会服务于 ...
- Spring Boot中使用Swagger2构建强大的RESTful API文档
由于Spring Boot能够快速开发.便捷部署等特性,相信有很大一部分Spring Boot的用户会用来构建RESTful API.而我们构建RESTful API的目的通常都是由于多终端的原因,这 ...
随机推荐
- 固定表头,单元格td宽度自适应,多内容出现-横向纵向滚动条数据表格的<前世今生>
固定表头,单元格td宽度自适应,多内容出现-横向纵向滚动条数据表格的<前世今生> 先上图例 & 无论多少数据--都完美! 背景:由于我司行业方向,需要很多数据报表,则t ...
- 微信小程序<web-view>嵌入网页后,小程序如何和网页交互传值?
最近开发一个项目由于小程序某些组件的限制,然后想到嵌入网页,但是遇到一个问题:网页端调取数据的时候需要 小程序传递多个参数值才能用,如何传值呢? 最初我想到是<web-view src=&quo ...
- UE4中FString转UTF8及UTF8转FString
FString转UTF8 FString szMsg = "test msg"; TCHAR* pSendData = szMsg.GetCharArray().GetData() ...
- PE文件详解(六)
这篇文章转载自小甲鱼的PE文件详解系列原文传送门 之前简单提了一下节表和数据目录表,那么他们有什么区别? 其实这些东西都是人为规定的,一个数据在文件中或者在内存中的位置基本是固定的,通过数据目录表进行 ...
- .NET使用Office Open XML导出超大数量数据到 Excel
我相信很多人在做项目的都碰到过Excel数据导出的需求,我从最开始使用最原始的HTML拼接(将需要导出的数据拼接成TABLE标签)到后来happy的使用开源的NPOI, EPPlus等开源组件导出EX ...
- Python pandas ERROR 2006 (HY000): MySQL server has gone away
之前在做python pandas大数据分析的时候,在将分析后的数据存入mysql的时候报ERROR 2006 (HY000): MySQL server has gone away 原因分析:在对百 ...
- Android语音识别--->>RecongnizerIntent实现
首先,咱得先说下注意点: Android中主要通过RecognizerIntent来实现语音识别,其实代码比较简单,但是如果找不到设置,就会抛出异常 ActivityNotFoundException ...
- [搬运]在C#使用.NET设计模式的新观点
原文地址:http://www.dotnetcurry.com/dotnet/1092/dotnet-design-patterns 软件开发有许多设计模式.其中一些模式非常受欢迎.说几乎所有的模式都 ...
- spring 多线程 写入数据库 和 写入 xml文件
最近工作中遇到一个需求 多线程先爬取页面 然后将爬取的结果持久化到数据库中 ,一些大文本的内容需要持久化到 xml文件中; 下面是运行后的结果: xml 文件写入结果: 数据库写入结果: 再来张项目结 ...
- nohup—后端守护进程
要将一个命令放到后台执行,我们一般使用nohup sh command & 为什么要nohup? 因为我用使用Scrt这种终端工具退出的时候会向我们在当前shell下启动的进程发生一个SIGH ...