springboot整合swagger
来源:互联网 发布:mysql数据库命令行 编辑:程序博客网 时间:2024/06/05 08:24
添加依赖
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.4.0</version></dependency><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.4.0</version></dependency>
配置Swagger
@SpringBootApplication@EnableScheduling@ServletComponentScanpublic class DemoApplication { //应用入口 public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } //swagger的配置 @Bean public Docket demoApi() { return new Docket(DocumentationType.SWAGGER_2) .groupName("演示环境") .genericModelSubstitutes(DeferredResult.class) // .genericModelSubstitutes(ResponseEntity.class) .useDefaultResponseMessages(false) .forCodeGeneration(false) .pathMapping("/") .select() .paths(PathSelectors.regex("/common.*"))//过滤的接口 .build() .apiInfo(demoApiInfo());//api介绍设置 } //API介绍信息 private ApiInfo demoApiInfo() { Contact contact = new Contact("qiming", "http://baidu.com", "2193714269@qq.com"); ApiInfo apiInfo = new ApiInfo("测试接口",//大标题 "REST风格API",//小标题 "0.1",//版本 "www.baidu.com", contact,//作者 "主页",//链接显示文字 ""//网站链接 ); return apiInfo; }}
访问接口文档
http://localhost/swagger-ui.html
一些问题
接口的返回的数据得足够清晰,太多干扰信息,可能会导致接口使用者无法甄别哪些是有用的数据。
0 0
- springboot整合swagger
- springboot整合swagger
- SpringBoot整合Swagger
- SpringBoot整合swagger
- SpringBoot整合Swagger
- Swagger与SpringBoot的整合
- springboot+mybatis+resteasy+swagger整合
- Swagger与SpringBoot的整合
- Springboot整合Swagger学习笔记
- springboot整合mybatis,swagger ui
- springmvc或者springboot整合swagger
- swagger 与 springboot 的整合实战
- springboot整合swagger UI 、spring-data-JPA
- SpringBoot开发案例之整合Swagger篇
- SpringBoot整合Swagger自动生成API文档
- SpringBoot开发案例之整合Swagger篇
- springboot + swagger
- springboot + swagger
- Android Studio提示错误:Error running app: Instant Run requires
- ROS简单的发布器节点和订阅器节点
- ORA-06502:PL/SQL :numberic or value error: character string buffer too small
- MDX查询
- xfire java.lang.IllegalStateException: Could not initialize Service
- springboot整合swagger
- ue4 创建c++工程失败解决方案
- JavaScript中set与get方法用法
- mysql 空间数据库中的各个方法函数
- javax.persistence.Table.indexes()异常原因
- UIImagePickerController调取系统相册图片
- WifiManager-Wifi Control App-Note
- java 获取Connection
- delphi基本语法(摘自博主:沈金强)