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 ...
随机推荐
- Date 对象
JavaScript Date 对象 Date 对象 Date 对象用于处理日期与时间. 创建 Date 对象: new Date() 以下四种方法同样可以创建 Date 对象: var d = ne ...
- mongodb批量处理
mongodb支持批量插入. 1.使用Java mongodb api 查看源码com.mongodb.MongoCollectionImpl,有两个方法 @Override public void ...
- Java开发工具汇总
1. Arthas 是Alibaba开源的Java诊断工具 Java动态追踪,对生产环境出现出现bug的情况下,无法调试处理问题,可以借鉴该工具进行问题分析. 原理介绍:Java动态追踪技术探究 Ar ...
- PHP:函数和语言结构(转)
转自:https://www.cnblogs.com/fanqiechaodan/articles/5222366.html 什么是语言结构呢?它和函数有什么不同吗? 1. 什么是语言结构和函数 语 ...
- BZOJ 2651 城市改建 树形DP+模拟?
题意 给一颗树,删除一条边再加一条边,使它仍为一颗树且任意两点间的距离的最大值最小. 题目数据范围描述有问题,n为1或重建不能使任意两点距离最大值变小,可以输出任意答案. 分析 删除一条边后会使它变成 ...
- nginx 配置文件 2019-12-20
cat /etc/nginx/nginx.conf user nginx; worker_processes ; error_log /var/log/nginx/error.log warn; p ...
- angularJS <input type="file> 图片的base64编码
talk is cheap show me the code <input type="file" id="file" name="file&q ...
- Linux Shell脚本,删除旧文件,保留最新的几个文件
删除某一目录下文件,只保留最新的几个 #!/bin/bash #保留文件数 ReservedNum= FileDir=/home/dev/saas_test/testcases/report/html ...
- [CSP-S模拟测试]:物理课(数学)
题目传送门(内部题144) 输入格式 从$physics.in$读入数据. 第一行一个数$T$,代表有$T$组数据.接下来$T$行每行$4$个浮点数,分别为$\theta,v,d,g$,保留到小数点后 ...
- cocos2dx热更新之后,闪退问题记录。
如果使用cocos2dx的3.17.2版本的官方热更新. 然后有玩家反馈说热更新之后游戏闪退,游戏内有部分资源没更到. 考虑如下几个方面调整. 1,在文件下载失败的时候,直接调用重新下载. 2,把下载 ...