在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的目的通常都是由于多终端的原因,这 ...
随机推荐
- python3之模块
1.python3模块 模块是一个包含所有你定义的函数和变量的文件,其后缀名是.py.模块可以被别的程序引入,以使用该模块中的函数等功能.这也是使用 python 标准库的方法. 模块让你能够有逻辑地 ...
- mysql安装及常见使用
mysql的安装和使用 说明:mysql是一个多线程,多用户的sql数据库,有着高性能,高可靠性,易于实用性等特点. 安装的软件链接:https://pan.baidu.com/s/1smRLkoX ...
- C# Main函数详解
2018-01-15 22:10:59 一.Main()方法的简介 1.唯一性.一般情况下,一个C#可执行程序只有一个Main函数,作为程序入口.但是在某些情况(如单元测试中),程序拥有多个Main ...
- 下载的js文件本地编辑器打开中文乱码如何解决
今天遇到的小问题,已解决,直接上图 下载直接打开是这样的 用记事本打开 另存为utf-8格式 正常了!
- wifi入侵思路
一.得到wifi密码 系统:Kali Linux 工具:Aircrack-ng,EWSA 方法: 1.WEP加密:deauth攻击:得到足够报文直接破解. 2.WPA加密:deau ...
- Java源码解读(一) 8种基本类型对应的封装类型
说起源码其实第一个要看的应该是我们的父类Object,这里就不对它进行描述了大家各自对其进行阅读即可. 一.八种基本类型 接下来介绍我们的八种基本类型(这个大家都知道吧):char.byte.shor ...
- 【转】Memory gates checking failed because the free memory***解决办法
Issue: Vault users cannot connect. VLOGS show the following error: Memory gates checking failed beca ...
- bzoj:1659: [Usaco2006 Mar]Lights Out 关灯
Description 奶牛们喜欢在黑暗中睡觉.每天晚上,他们的牲口棚有L(3<=L<=50)盏灯,他们想让亮着的灯尽可能的少.他们知道按钮开关的位置,但喜闻乐见的是他们并没有手指.你得到 ...
- BZOJ 1800: [Ahoi2009]fly 飞行棋【思维题,n^4大暴力】
1800: [Ahoi2009]fly 飞行棋 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1689 Solved: 1335[Submit][St ...
- Codeforces 626B Cards(模拟+规律)
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...