博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
七、集成swagger2
阅读量:6857 次
发布时间:2019-06-26

本文共 1532 字,大约阅读时间需要 5 分钟。

1、添加依赖

io.springfox
springfox-swagger2
2.2.2
io.springfox
springfox-swagger-ui
2.2.2

 

2、添加配置

package com.biniu.config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import springfox.documentation.builders.ApiInfoBuilder;import springfox.documentation.builders.PathSelectors;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;/** * swagger2配置 * @author lay * @date 2018/4/15. * @time 15:58 */@Configuration@EnableSwagger2public class Swagger2 {    @Bean    public Docket createRestApi() {        return new Docket(DocumentationType.SWAGGER_2)                .apiInfo(apiInfo())                .select()                .apis(RequestHandlerSelectors.basePackage("com.biniu.controller"))                .paths(PathSelectors.any())                .build();    }    private ApiInfo apiInfo() {        return new ApiInfoBuilder()                .title("springboot中使用swagger2创建apis")                .version("v1.0")                .build();    }}

 

转载于:https://www.cnblogs.com/lay2017/p/8847973.html

你可能感兴趣的文章
seajs和requirejs对比;node初识
查看>>
JS函数
查看>>
(转)linux下vi命令修改文件及保存的使用方法
查看>>
循环中else的用法
查看>>
Reverse String
查看>>
linux安装ffmpeg
查看>>
第三期 轨迹生成——2.运动规划问题
查看>>
PHP 从数组对象中取出数组提示:Undefined property: stdClass::$subject
查看>>
存储过程
查看>>
ext组件中的查询
查看>>
Python笔记总结week1
查看>>
c#中使用NetCDF存储二维数据的读写操作简单应用
查看>>
linux网络相关命令使用
查看>>
java基础(二)
查看>>
cocos2d中的anchorPoint
查看>>
记录一下:chrome上,把网页保存为文件的插件
查看>>
C#和Javascript间互转的Xxtea加解密
查看>>
BAT批处理中的字符串处理详解(字符串截取)
查看>>
智力题集锦【二】
查看>>
读 《我为什么放弃Go语言》 有感
查看>>