其他分享
首页 > 其他分享> > 使用swagger生成实时接口文档

使用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

标签:swagger,EnableSwagger2,swagger2,文档,接口,ui,springfox
来源: https://www.cnblogs.com/wangyang9629/p/12861060.html