spring-boot集成3:集成swagger
Why swagger?
使用swagger让你从编写接口文档的无聊工作中解脱出来
1.Maven依赖
<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<!-- swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
2.Swagger配置类
使用自定义Swagger配置类可以自定义一些swagger配置,比如设置要扫描的base package,也可以不用Swagger配置类,使用默认配置。
package com.zhya.config; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; /**
* swagger 配置类
*
* @Author zhangyang
* @Date 下午 8:57 2018/11/20 0020
**/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket getDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.zhya.controller"))
.paths(PathSelectors.any())
.build();
}
}
3.实例


spring-boot集成3:集成swagger的更多相关文章
- 15、Spring Boot 2.x 集成 Swagger UI
1.15.Spring Boot 2.x 集成 Swagger UI 完整源码: Spring-Boot-Demos 1.15.1 pom文件添加swagger包 <swagger2.versi ...
- spring boot / cloud (三) 集成springfox-swagger2构建在线API文档
spring boot / cloud (三) 集成springfox-swagger2构建在线API文档 前言 不能同步更新API文档会有什么问题? 理想情况下,为所开发的服务编写接口文档,能提高与 ...
- Spring Boot HikariCP 一 ——集成多数据源
其实这里介绍的东西主要是参考的另外一篇文章,数据库读写分离的. 参考文章就把链接贴出来,里面有那位的代码,简单明了https://gitee.com/comven/dynamic-datasource ...
- Spring Boot系列——如何集成Log4j2
上篇<Spring Boot系列--日志配置>介绍了Spring Boot如何进行日志配置,日志系统用的是Spring Boot默认的LogBack. 事实上,除了使用默认的LogBack ...
- 【ELK】4.spring boot 2.X集成ES spring-data-ES 进行CRUD操作 完整版+kibana管理ES的index操作
spring boot 2.X集成ES 进行CRUD操作 完整版 内容包括: ============================================================ ...
- 14、Spring Boot 2.x 集成 Druid 数据源
14.Spring Boot 2.x 集成 Druid 数据源 完整源码: Spring-Boot-Demos
- 12、Spring Boot 2.x 集成 MongoDB
1.12 Spring Boot 2.x 集成 MongoDB 完整源码: Spring-Boot-Demos
- 11、Spring Boot 2.x 集成 HBase
1.11 Spring Boot 2.x 集成 HBase 完整源码: Spring-Boot-Demos
- 10、Spring Boot 2.x 集成 Log4j2
1.10 Spring Boot 2.x 集成 Log4j2 完整源码: Spring-Boot-Demos
- 9、Spring Boot 2.x 集成 Thymeleaf
1.9 Spring Boot 2.x 集成 Thymeleaf 完整源码: Spring-Boot-Demos 1.9.1 在pom中引入依赖 <dependency> <grou ...
随机推荐
- Linux用户账号文件——passwd
/etc/passwd文件是UNIX安全的关键文件之一.该文件用于用户登录时校验用户的登录名.加密的口令数据项.用户ID(UID).默认的用户组ID(GID).用户信息.用户主目录以及登录后使用的sh ...
- IDEA部署Tomcat报错:No artifacts marked for deployment
刚开始碰到这个问题还被坑了,搞了好半天...所以我准备记录一下,走的弯路就不说了,因为我没图
- TCP协议(包括TCP的连接过程,数据分段,TCP有关服务器优化)
Transmission Control Protocol/Internet Protocol 传输控制协议/因特网互联协议 TCP/IP是一个Protocol Stack(协议栈),包括TCP.IP ...
- Task底层实现原理探秘
.NET 4包含新名称空间System.Threading.Tasks,它 包含的类抽象出了线程功能, 在底层使用ThreadPool. 任务表示应完成的某个单元的工作. 这个单元的工作可以在单独的线 ...
- BZOJ 4032: [HEOI2015]最短不公共子串 (dp*3 + SAM)
转博客大法好 第4个子任务中,为什么只转移最近的一个位置,自己YY吧(多YY有益身体健康). #include <bits/stdc++.h> using namespace std; t ...
- 2019CCPC秦皇岛(重现赛)-D
链接: http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1004&cid=872 题意: 给定一个正整数 n,要求判断 1 ...
- python--AutoPy库
包括用于控制键盘和鼠标,在屏幕上查找颜色和位图以及显示警报的功能 - 所有这些都是以跨平台,高效和简单的方式进行的.适用于Mac OS X,Windows和X11 中文文档:https://blog. ...
- 怎么理解vue中$listeners属性?
首先,$listeners是什么? 假设有父组件Parent和子组件Child // Parent <template> ... <child v-on:event-one=&quo ...
- 导出excel 各 cvs 的方法
public function orderExcelExport($data,$filename='simple.xls'){ ini_set('max_execution_time', '0'); ...
- Monkey初步使用
版权声明: 本账号发布文章均来自公众号,承香墨影(cxmyDev),版权归承香墨影所有. 允许有条件转载,转载请附带底部二维码. 一.什么是Monkey Monkey是Android自身提供的,可以通 ...