Spring Boot 2.X整合Swagger2

 时间:2024-11-04 01:36:43

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

Spring Boot 2.X整合Swagger2

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

Spring Boot 2.X整合Swagger2

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

Spring Boot 2.X整合Swagger2

4、配置Swagger2

Spring Boot 2.X整合Swagger2

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

Spring Boot 2.X整合Swagger2

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

Spring Boot 2.X整合Swagger2

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

Spring Boot 2.X整合Swagger2Spring Boot 2.X整合Swagger2
  • spring boot整合freemarker模板引擎框架
  • spring boot整合ehcache缓存框架
  • springboot集成swagger2访问路径404
  • spring boot全局异常处理
  • Spring Boot入门教程
  • 热门搜索
    实践经历怎么写 怎么按摩丰胸 薇诺娜怎么样 皇太极怎么死的 手指麻木是怎么回事 怎么注册邮箱帐号 大写字母怎么写 电脑怎么连接路由器 头发毛躁怎么办 数学怎么才能学好