spring boot 中使用swagger
一、pom.xml
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
二、创建Swagger2类
@Configuration
@EnableSwagger2
public class Swagger2 {
@Bean
public Docket createRestApi() {
List<Parameter> pars = new ArrayList<Parameter>();
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
.paths(PathSelectors.any())
.build()
.globalOperationParameters(pars)
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("小王 RESTful API")
.description("使用swagger2结合写api")
.termsOfServiceUrl("https://www.cnblogs.com/")
.version("1.0")
.build();
}
}
三、启动位置配置
@SpringBootApplication
@EnableSwagger2
public class SmlzApplication {
public static void main(String[] args) {
SpringApplication.run(SmlzApplication.class, args);
}
}
四、使用
@PostMapping("/save-book")
@ApiOperation(value = "添加书籍",notes = "暂时没连接数据库")
public Book saveBook(@RequestBody Book book){
return bookSerivce.insertByBook(book);
}
spring boot 中使用swagger的更多相关文章
- Spring Boot中使用Swagger CodeGen生成REST client
文章目录 什么是Open API规范定义文件呢? 生成Rest Client 在Spring Boot中使用 API Client 配置 使用Maven plugin 在线生成API Spring B ...
- spring boot 中使用swagger 来自动生成接口文档
1.依赖包 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swa ...
- Spring Boot 中使用 Swagger
前后端分离开发,后端需要编写接⼝说明⽂档,会耗费⽐较多的时间. swagger 是⼀个⽤于⽣成服务器接⼝的规范性⽂档,并且能够对接⼝进⾏测试的⼯具. 作用 ⽣成接⼝说明⽂档 对接⼝进⾏测试 使用步骤 ...
- 【swagger】1.swagger提供开发者文档--简单集成到spring boot中【spring mvc】【spring boot】
swagger提供开发者文档 ======================================================== 作用:想使用swagger的同学,一定是想用它来做前后台 ...
- Spring Boot中使用Swagger2构建强大的RESTful API文档
由于Spring Boot能够快速开发.便捷部署等特性,相信有很大一部分Spring Boot的用户会用来构建RESTful API.而我们构建RESTful API的目的通常都是由于多终端的原因,这 ...
- Spring Boot中使用Swagger2构建API文档
程序员都很希望别人能写技术文档,自己却很不愿意写文档.因为接口数量繁多,并且充满业务细节,写文档需要花大量的时间去处理格式排版,代码修改后还需要同步修改文档,经常因为项目时间紧等原因导致文档滞后于代码 ...
- 在Spring Boot中使用swagger-bootstrap-ui
在Spring Boot中使用swagger-bootstrap-ui swagger-bootstrap-ui是基于swagger接口api实现的一套UI,因swagger原生ui是上下结构的,在浏 ...
- Spring Boot中使用Swagger2构建RESTful APIs
关于 Swagger Swagger能成为最受欢迎的REST APIs文档生成工具之一,有以下几个原因: Swagger 可以生成一个具有互动性的API控制台,开发者可以用来快速学习和尝试API. S ...
- Spring Boot中使用Swagger2自动构建API文档
由于Spring Boot能够快速开发.便捷部署等特性,相信有很大一部分Spring Boot的用户会用来构建RESTful API.而我们构建RESTful API的目的通常都是由于多终端的原因,这 ...
随机推荐
- picoctf_2018_rop chain
拿到题目就知道要用rop来做 老样子日常检查一下 32位的程序开启了nx和relro保护 将程序放入ida中 一眼就看到了程序中的后门程序 我们逐一分析一下 main vuln get没有对输入字符进 ...
- BJD4th pwn pi
没记错的话,比赛那天正好是圣诞节,就只看了这一道pwn题,我还没做出来.我太菜了. 有一说一,ida换成7.5版本之后,一些去掉符号表的函数也能被识别出来了,ida更好用了呢. 题目程序分为两块,先看 ...
- uniapp-uView表单中如何添加日期控件?
环境:uniapp,uview-ui,Picker 选择器, 本次我们用uview中的Picker 选择器来写一个日期功能 此选择器有四种弹出模式 一是时间模式,可以配置年,日,月,时,分,秒参数二是 ...
- JS(JQuery) 省市区三级联动下拉选择
引入 area.js /* * 全国三级城市联动 js版 */ function Dsy(){ this.Items = {}; } Dsy.prototype.add = function(id,i ...
- cmake引入第三方库的debug和release版本之Windows版本
概述 本文将介绍cmak引入第三方库debug和release不同配置. Windows上,习惯将debug模式下生成的动态库名后缀添加D 以作和release区分.cmake创建一个项目A,A引入动 ...
- C++ 获取函数耗时
C++ 记录耗时 #include <sys/timeb.h> #include <stdio.h> long long getSystemTime() { struct ti ...
- 【LeetCode】978. Longest Turbulent Subarray 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 虫取法 日期 题目地址:https://leetco ...
- 【LeetCode】547. Friend Circles 解题报告(Python & Java & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
- DEV GridControl小结。。
[转]DEV GridControl小结.. 来自:http://www.cnblogs.com/yuerdongni/archive/2012/09/08/2676753.html 1. 如何解 ...
- 第十个知识点:RSA和强RSA问题有什么区别?
第十个知识点:RSA和强RSA问题有什么区别 这个密码学52件事数学知识的第一篇,也是整个系列的第10篇.这篇介绍了RSA问题和Strong-RSA问题,指出了这两种问题的不同之处. 密码学严重依赖于 ...