SpringBoot(九) - Swagger
1、依赖
<!-- swagger 核心 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
2、核心启动类的注解
@EnableSwagger2 //启用 Swagger
@EnableSwaggerBootstrapUI //启用 BootstrapUI
//经过测试 只添加 @EnableSwagger2 就可以 (如果不可以再添加试试)
3、Swagger 的 注解解释
3.1 实体上的注解
//模型数据对应的 实体注解
@ApiMode(value = "",description = "")
//模型数据对应的 属性注解
@ApiModelProperty(value = "")
3.2 controller上的注解
//写在controller上面,用于描述当前处理类支持的主要功能,包括版本说明
@Api(tags = "")
//写在目标请求处理方法上,用户描述当前方法支持的功能,属性value-方法的概述描述,属性notes-方法的详细描述
@ApiOperation(value = "",notes = "")
//参数说明注解,将接口的所有参数说明,进行归类,避免多个参数@ApiParam
@ApiImplicitParams(
@ApiImplicitParam(required = false,name = "",value = "")
)
//响应码和响应说明
@ApiResponses({
@ApiResponse(code = 201,message = "参数为空"),
@ApiResponse(code = 202,message = "参数非法")
})
//参数说明注解
@RequestParam(value = "",required = false)
4、UI界面
4.1 ui 依赖
<!-- swagger ui 界面 swagger-ui.html 官方ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<!-- swagger-bootstrap-ui包 /doc.html 推荐使用 bootstrap 的ui -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.3</version>
</dependency>
<!-- 引入swagger-ui-layer包 /docs.html 了解-->
<dependency>
<groupId>com.github.caspar-chen</groupId>
<artifactId>swagger-ui-layer</artifactId>
<version>1.1.3</version>
</dependency>
<!-- 引入swagger-mg-ui 包 /document.html 了解 -->
<dependency>
<groupId>com.zyplayer</groupId>
<artifactId>swagger-mg-ui</artifactId>
<version>1.0.6</version>
</dependency>
4.2 UI页面的展示
4.2.1 swagger 官方UI页面

4.2.2 bootstrap 的UI页面

SpringBoot(九) - Swagger的更多相关文章
- 整合 springboot 和 swagger出问题
整合 springboot 和 swagger ,出现报错, org.springframework.beans.factory.UnsatisfiedDependencyException: Err ...
- SpringBoot集成Swagger接口管理工具
手写Api文档的几个痛点: 文档需要更新的时候,需要再次发送一份给前端,也就是文档更新交流不及时. 接口返回结果不明确 不能直接在线测试接口,通常需要使用工具,比如postman 接口文档太多,不好管 ...
- SpringBoot 整合swagger
springBoot 整合swagger 1.pom.xml 配置 <dependency> <groupId>io.springfox</groupId> < ...
- spring-boot 集成 swagger 问题的解决
spring-boot 集成 swagger 网上有许多关于 spring boot 集成 swagger 的教程.按照教程去做,发现无法打开接口界面. 项目由 spring mvc 迁移过来,是一个 ...
- springboot 集成swagger ui
springboot 配置swagger ui 1. 添加依赖 <!-- swagger ui --> <dependency> <groupId>io.sprin ...
- SpringBoot整合Swagger和Actuator
前言 本篇文章主要介绍的是SpringBoot整合Swagger(API文档生成框架)和SpringBoot整合Actuator(项目监控)使用教程. SpringBoot整合Swagger 说明:如 ...
- springboot之swagger快速启动
springboot之swagger快速启动 简介 介绍 可能大家都有用过swagger,可以通过ui页面显示接口信息,快速和前端进行联调. 没有接触的小伙伴可以参考官网文章进行了解下demo页面. ...
- SpringBoot整合Swagger实战
源码地址:https://github.com/laolunsi/spring-boot-examples 目前SpringBoot常被用于开发Java Web应用,特别是前后端分离项目.为方便前后端 ...
- 【SpringBoot | Swagger】SpringBoot整合Swagger
SpringBoot整合Swagger 1. 什么是Swagger Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.简单说就是项目跑起来了, ...
- SpringBoot与Swagger整合
1 SpringBoot与Swagger整合https://blog.csdn.net/jamieblue1/article/details/99847744 2 Swagger详解(SpringBo ...
随机推荐
- Python获取jenkins job信息
pip install Python-jenkins 如果只是想获取到jenkins的全局变量(比如job url),使用jenkins全局变量就能做到. https://www.jb51.net/ ...
- Python 抓取猫眼电影排行
import json import re import requests from requests.exceptions import RequestException import time # ...
- gh-ost工具在线改表过程的详细解析
gh-ost,是github开源的一款在线修改MySQL表结构的工具https://github.com/github/gh-ost/,它不使用pt-osc的触发器机制,而是使用解析binlog来实现 ...
- 动态配置生成echarts图表
动态配置x轴和y轴的数据,并且可以选择柱状图.折线图.饼状图等图形 父组件代码: <template> <div class="reportPicture"> ...
- Educational Codeforces Round 155 (Rated for Div
B. Chips on the Board 题解:贪心 显然我们可以把题意转化为:对于任意一个\((i,j)\),我们可以花费\(a_{i,j}\)的代价占据第\(i\)行和第\(j\)列,求占据所有 ...
- Element-UI 中关于 Table 的几个功能点简介(行列的合并和样式、合计行配置等)
〇.前言 本文记录了关于 Element 框架中 Table 的几个功能点,后续将持续更新. el-table 官网地址:https://element.eleme.cn/#/zh-CN/compon ...
- Java基础 —— 集合(一)
集合(一) 数组和集合的区别 数组是固定长度的数据结构,而集合是动态的数据结构 数组可以包含基本数据类型和对象,集合只能包含对象 数组只能存放同一类型的数据,而集合可以蹲房不同类型的 数组可以直接访问 ...
- 斐波那契数列(Java实现)
斐波那契数列 题目描述: 悲波那契数列(Fibonacci sequence)又称黄金分割数列,因数学家莱昂纳多·裴波那契(LeonardodaFibonacci)以兔子繁殖为例子而引入,故又称为&q ...
- Mysql8.0修改配置参数lower_case_table_names
现象 今天在配置一个环境的数据库,所使用的系统要求该数据库 lower_case_table_names = 1 (对数据库表明.列名大小写不敏感) 我看了一下,在 Windows 上,默认值为 1. ...
- HTMLDivElement.prototype
HTMLDivElement.prototype.test = function(){console.log("i am div")} $0.innerHTML = '<di ...