Swagger

在spring boot中集成Swagger

新建一个swagger项目

maven依赖
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version>
</dependency><!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version>
</dependency>
编写配置类
@Configuration
@EnableSwagger2
public class SwaggerConfig {@Beanpublic Docket docket(Environment environment){boolean flag = environment.acceptsProfiles(Profiles.of("dev","test"));return new Docket(DocumentationType.SWAGGER_2).apiInfo(new ApiInfo("Api Documentation","Api Documentation","1.0","",new Contact("yao","",""),"pandown 1.0","http://www.apache.org/licenses/LICENSE-2.0",new ArrayList()))    //定义ApiInfo.enable(flag)   //是否启用sawwger.groupName("组名")   //配置分组.select().apis(RequestHandlerSelectors.basePackage("com.wenyao.swagger.controller"))   //包扫描.paths(PathSelectors.ant("/"))  //路径过滤.build();}}
@ApiModel和@ApiModelProperty

@ApiModel用于给一个类添加描述名

@ApiModelProperty给属性添加描述

@ApiModel("用户")
public class User {@ApiModelProperty("编号")private int id;@ApiModelProperty("用户名")private String username;@ApiModelProperty("密码")private String password;
}
@ApiOperation和@ApiParam
@RestController
public class HelloController {@ApiOperation("接口注释")@RequestMapping("/hello")public String hello(){return "hello";}public String hello2(@ApiParam("参数注释") String var){return "hello";}
}

在spring boot中集成Swagger相关推荐

  1. Spring Boot中使用Swagger CodeGen生成REST client

    文章目录 什么是Open API规范定义文件呢? 生成Rest Client 在Spring Boot中使用 API Client 配置 使用Maven plugin 在线生成API Spring B ...

  2. 新手入门教程-------Spring Boot中集成RabbitMQ

    AMQP:是Advanced Message Queuing Protocol的简称,高级消息队列协议,是一个面向消息中间件的开放式标准应用层协议. 定义了以下特性: 消息方向 消息队列 消息路由(包 ...

  3. spring boot中利用mybatis-generator插件生成代码

    使用Idea在spring boot中集成mybatis-generator,自动生成mapper.xml  model  dao 文件 一.配置 pom.xml 在pom.xml的<plugi ...

  4. mybatis注解开发_Spring Boot 中集成 MyBatis

    阅读本文约需要5分钟 大家好,我是你们的导师,我每天都会在这里给大家分享一些干货内容(当然了,周末也要允许老师休息一下哈).上次老师跟大家分享了Spring Boot 中的AOP处理,今天给大家分享下 ...

  5. redis 支持 json_Spring Boot 中集成 Redis

    阅读本文约需要5分钟 大家好,我是你们的导师,我每天都会在这里给大家分享一些干货内容(当然了,周末也要允许老师休息一下哈).上次老师跟大家分享了 Spring Boot 中的拦截器,今天跟大家分享下 ...

  6. 赠书:Kotlin在Spring Boot中的应用

    点击上方蓝色"程序猿DD",关注我 每周福利送不停! 随着Kotlin在移动端开发的普及,它也逐步走入后端开发者的视野.Kotlin是JVM体系的语言,和Java有着良好的互操作性 ...

  7. Spring Boot中使用Swagger2构建RESTful APIs

    关于 Swagger Swagger能成为最受欢迎的REST APIs文档生成工具之一,有以下几个原因: Swagger 可以生成一个具有互动性的API控制台,开发者可以用来快速学习和尝试API. S ...

  8. boot spring 接口接收数据_在 Spring Boot 中使用 Dataway 配置数据查询接口

    Dataway介绍 Dataway 是基于 DataQL 服务聚合能力,为应用提供的一个接口配置工具.使得使用者无需开发任何代码就配置一个满足需求的接口. 整个接口配置.测试.冒烟.发布.一站式都通过 ...

  9. Spring Boot中的微信支付(小程序)

    前言 微信支付是企业级项目中经常使用到的功能,作为后端开发人员,完整地掌握该技术是十分有必要的. 一.申请流程和步骤 图1-1 注册微信支付账号 获取微信小程序APPID 获取微信商家的商户ID 获取 ...

最新文章

  1. PyCharm_10个加速省时间技巧
  2. 虚拟机(VMware Workstation Pro)安装多台Linux
  3. Package 'xxxx' is not installed, so not removed
  4. 【Android基础】页面跳转与传值(Activity跳转与传值)
  5. 如何使用 Java 调取 Python、R 的训练模型?
  6. 数据治理中哪3点最重要
  7. SQLyog备份数据库
  8. linux 新建文件夹命令
  9. cropper左右移动_cropper.js移动端使用
  10. 【信息系统项目管理师】12项目合同管理
  11. uint8_t范围_uint8_t / uint16_t / uint32_t /uint64_t 是什么数据类型 - 大总结,看完全明白了...
  12. 计算机学院云毕业,“云端”相约,逐梦起航——计算机与设计学院举办2020届线上毕业典礼...
  13. 深入浅出Linux操作系统权限管理与网络配置(三)
  14. SQL Server中的日期和时间:DATEADD()
  15. 实验6:安装EVE-NG
  16. MySQL常见错误码
  17. 盘点2022年nft艺术品交易平台排行榜
  18. Blockchain for Internet of Energy management: Review, solutions, and challenges
  19. 面试常见几种排序算法 Java代码总结
  20. php如何设置邮箱,phpcms邮箱如何设置

热门文章

  1. Java 动态写轮眼 SharinganJPanel (整理)
  2. 字符集GBK升级UTF8
  3. python 内置的os模块将文件夹下所有图片名称加上指定字符
  4. 订餐系统之同步饿了么商家订单
  5. 当 IDENTITY_INSERT 设置为 OFF 时,不能为表中的标识列插入显式值
  6. ASP.NET MVC中在Action获取提交的表单数据方法总结
  7. sql with as 用法
  8. 数据分析TB级别数据量大了怎么办,不会代码模型训练怎么办?
  9. Python机器学习笔记:XgBoost算法(亲测)
  10. Go的协程与Swoole的协程的区别:环境支持 线程