使用swagger生成实时接口文档

1) 引入Swagger2和swagger ui (在父工程中依赖)

<!-- 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>

2) 编写配置类(@EnableSwagger2 开启swagger2自动生成api文档功能)

package com.atguigu.user.config;

 

import org.springframework.context.annotation.Configuration;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

 

@EnableSwagger2  //开启swagger2自动生成api文档的功能

@Configuration

public class AppSwaggerConfig {

 

}

http://localhost:8080/swagger-ui.html

上一篇:Springboot系列(七) 集成接口文档swagger,使用,测试


下一篇:了解前后端分离 ,学习Swagger的使用, 在SpringBoot中集成Swagger