spring-boot集成swagger
1、引入swagger需要的java类库
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.0</version>
</dependency> <dependency>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
<version>1.3.1</version>
</dependency>
2、引入SwaggerConfig.java类,并配置
package com.coracle.positec.xweb.swagger; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex; /**
* SwaggerConfig
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
/**
* 可以定义多个组,比如本类中定义把test和demo区分开了 (访问页面就可以看到效果了)
*
*/
@Bean
public Docket testApi() {
return new Docket(DocumentationType.SWAGGER_2) .groupName("api_bsd")
.genericModelSubstitutes(DeferredResult.class)
.useDefaultResponseMessages(false)
.forCodeGeneration(false)
.pathMapping("/")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.coracle.positec.xweb.controller")).build();
} private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("保时得项目RESTful API")
.description("保时得项目中构建RESTful API")
.termsOfServiceUrl("")
.contact("huangbaidong")
.version("1.0")
.build();
}
}
3、配置Controller接口注解
swagger类注释
@Api(value = "订单类",tags = "订单类测试接口") swagger接口注释
@ApiOperation("订单列表")
swagger参数注释
@ApiParam("订单ID")
4、配置实体注解
swagger实体类注释
@ApiModel("订单实体类")
swagger实体类中隐藏属性
@ApiModelProperty(hidden = true)
swagger实体属性备注
@ApiModelProperty("订单编号")
spring-boot集成swagger的更多相关文章
- Spring Boot 集成 Swagger,生成接口文档就这么简单!
之前的文章介绍了<推荐一款接口 API 设计神器!>,今天栈长给大家介绍下如何与优秀的 Spring Boot 框架进行集成,简直不能太简单. 你所需具备的基础 告诉你,Spring Bo ...
- Spring Boot 集成Swagger
Spring Boot 集成Swagger - 小单的博客专栏 - CSDN博客https://blog.csdn.net/catoop/article/details/50668896 Spring ...
- spring boot集成swagger,自定义注解,拦截器,xss过滤,异步调用,guava限流,定时任务案例, 发邮件
本文介绍spring boot集成swagger,自定义注解,拦截器,xss过滤,异步调用,定时任务案例 集成swagger--对于做前后端分离的项目,后端只需要提供接口访问,swagger提供了接口 ...
- 【Swagger】可能是目前最好的 Spring Boot 集成 swagger 的方案
[Swagger]可能是目前最好的Spring Boot集成 swagger 的方案  Swagger 是一个规范和完整的框架,用于生成.描述. ...
- Spring boot 集成 Swagger
添加依赖包 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swa ...
- spring boot集成swagger文档
pom <!-- swagger --> <dependency> <groupId>io.springfox</groupId> <artifa ...
随机推荐
- IOS基于XMPP协议开发--XMPPFramewok框架(三):用户注册
接着上面说 用户注册是比较简单的,成功连接上服务器后,设置好JID,即可调用 [_xmppStream registerWithPassword:pwd error:&err] 进行注册 -( ...
- atitit.thumb生成高质量缩略图 php .net c++ java
atitit.java thumb生成高质量缩略图 php .net c++ 1. 图像缩放(image scaling)---平滑度(smoothness)和清晰度(sharpness) 1 2. ...
- 浅谈I2C总线
I2C总线概述 I2C(Inter-Integrated Circuit)总线是一种由PHILIPS公司在80年代开发的两线式串行总线,用于连接微控制器及其外围设备.I2C总线最主要的优点是其简单性和 ...
- 响应式布局框架 Pure-CSS 5.0 示例中文版-上
0. Pure-CSS 介绍 Pure CSS 是雅虎出品的 CSS 框架, 依托于Normalize.CSS,在不适用任何JS代码情况下即可实现响应式布局的轻量级框架,无依赖,体积小. 1. CDN ...
- path方法总结
$.mobile.path.get(url);//获取URL地址的目录部分,就是除了a.html之外的那部分 jQuery.mobile.path.getDocumentBase(bool) //获取 ...
- Win7-U盘安装出现"We were unable to copy your files. "
使用Windows 7 USB/DVD Download Tool时,提示We were unable to copy your files. Please check your USB device ...
- Windows版变色龙
打包安装版本更新源地址: http://www.insanelymac.com/forum/files/file/59-chameleon-22-svn/ 一.使用方法:1.安装Windows版变色龙 ...
- python学习笔记(3)--IDLE双击运行后暂停
本来想找一个python的IDE什么的,用过pycharm,vs装python插件,软件都太大了,习惯了用sublime写html,js这样的简直受不了. 一直坚持用着python自带的IDLE,不过 ...
- 超赞的lua开发工具zerobrane
zerobrane是用lua和wxWidgets编写的ide,而且是跨平台的,支持多种lua解释器,包括love2d. 而且最赞的是支持即时编程,可以在运行时直接修改变量,直接看到结果,不用重新运行, ...
- web应用中幂等性的学习
qnmd bd:待会劳资就去买个vpn. 在平常的工作中经常听到也用到幂等,却没有及时学习总结这个知识点,现在到时候了. 幂等性最初是一个数学上的概念:在某二元运算下,幂等元素是指被自己重复运算(或对 ...