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 ...
随机推荐
- php回调函数call_user_func和call_user_func_array详解
call_user_func($fun); call_user_func 函数类似于一种特别的调用函数的方法,使用方法如下: 1.调用 普通函数: <?php function a($b, $c ...
- 雅虎天气API调用
雅虎天气API调用: 1.调用方法:http://weather.yahooapis.com/forecastrss?w=2502265&u=c,绿色字体为城市代号,u=c表示取摄氏度. 2. ...
- Redis(十七):批量操作Pipeline
大多数情况下,我们都会通过请求-相应机制去操作redis.只用这种模式的一般的步骤是,先获得jedis实例,然后通过jedis的get/put方法与redis交互.由于redis是单线程的,下一次请求 ...
- java后台分页实例一
后台框架:jfinal + velocity.前台框架:jquery 页面 <!DOCTYPE html> <html> <head> <meta char ...
- atitit.orm的缺点与orm框架市场占有率,选型attilax总结
atitit.orm的缺点与orm框架市场占有率,选型attilax总结 1. attilax的orm框架要求 1 2. orm框架市场占有率 2 3. spring jdbc templt 3 4. ...
- mysql 主主复制(双主复制)binlog-do-db
[root@DB ~]# grep "binlog-do-db" /etc/my.cnf binlog-do-db = test [root@DB-S ~]# grep " ...
- 快速过滤出完整的SQL语句
[root@bass ca]# mysqlbinlog -- |egrep -v "^(/|SET|BEGIN|COMMITER|#|COMMIT)" >a.log [roo ...
- cocos2d-x 之 CCProgressTimer
--绕圆心转动的进度动画 local function SpriteProgressToRadial() local leftProgress = CCProgressTimer:create(CCS ...
- Caliburn Micro框架快速上手(WP)
一.使用nuget添加起始工程 二.修改App.xaml文件和App.xaml.cs文件 AppBootstrapper介绍: AppBootstrapper根据中文的直译可以 ...
- [systemd]Linux系统启动之systemd
参照:https://wiki.debian.org/systemd 最近在添加板子应用程序自启动的时候,发现在rcN.d中的符号链接并没有用,文件系统为Debian Jessie 8, 后来从同事那 ...