springmvc 整合 swagger2
来源:互联网 发布:网络社会组织 编辑:程序博客网 时间:2024/05/19 12:25
1.在springmvc 中添加swagger2 的maven依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
2.在Spring IOC 容器中注册swagger2的启动类
<bean id="swagger2Config" class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration"></bean>
3.在springmvc中配置访问swagger2的静态页面的配置
<mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"/>
<mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>
4.建立一个controller类
@Api(description = "用户列表") 注解整个类 现在里面的 description 属性已经过期
@ApiOperation(value = "sprimvc test", httpMethod = "GET", notes = "用于测试springmvc的方法")
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
2.在Spring IOC 容器中注册swagger2的启动类
<bean id="swagger2Config" class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration"></bean>
3.在springmvc中配置访问swagger2的静态页面的配置
<mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"/>
<mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>
4.建立一个controller类
@Api(description = "用户列表") 注解整个类 现在里面的 description 属性已经过期
@ApiOperation(value = "sprimvc test", httpMethod = "GET", notes = "用于测试springmvc的方法")
注释一个Handel
启动项目,然后访问路径
http://localhost:8080/swagger-ui.html
好的,到这里就已经成功了
文章翻译自github官网
阅读全文
0 0
- springmvc+swagger2整合
- springmvc 整合 swagger2
- SpringMVC整合Swagger2
- SpringMVC整合swagger2
- SpringMVC中使用Swagger2整合
- swagger2 与 springmvc 整合 生成接口文档
- Spring MVC 整合 Swagger2
- Spring Boot整合Swagger2
- spring boot整合Swagger2
- SpringBoot整合Swagger2
- spring boot 整合Swagger2
- Swagger2+SpringMVC配置详解
- SpringMVC + Swagger2 的使用
- SpringMvc 集成swagger2
- SpringMVC集成swagger2
- 如何整合SpringMVC和Swagger2,并且使用Mock数据进行联调
- 个人推荐:SpringBoot整合Swagger2
- SpringMvc 3分钟集成swagger2
- 补补嵌入式系统基础知识
- 排序算法
- jass 重置英雄
- Python数据分析基础(四)——数据文件处理
- 你要知道的游戏开发新手入门指南
- springmvc 整合 swagger2
- Generate Parentheses
- 端口分类调研
- java的BIO实现
- Python数据分析基础(五)——数据规整
- 移动端1px像素设置
- 3 Composer难理解?那么说明你对PHP这些功能不了解
- 省队集训Round2 DAY2
- jQuery源码阅读(一)---jQuery源码整体架构