1、在pom.xml中添加swagger2的坐标

2、在pom.xml中添加swagger-ui的坐标

3、新建一个Swagger2的配置类
加注解
@EnableSwagger2@Configuration

4、配置Swagger2

5、在Controller层添加API注解
@Api("用户接口")
@ApiOperation("获取所有用户")

6、启动项目,在浏览器输入网址
http://localhost/swagger-ui.html

7、点击try it out!进行测试
我这里写了一个查询所有用户的列子

