spring+sewwager在线文档生成器使用过程中遇到问题的分享
来源:互联网 发布:红五星3d图库永久域名 编辑:程序博客网 时间:2024/05/22 06:29
刚开始使用springmvc+sewagger时总是弄不好因为网上推荐的是,
<!-- swagger-springmvc --> <dependency> <groupId>com.mangofactory</groupId> <artifactId>swagger-springmvc</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>com.mangofactory</groupId> <artifactId>swagger-models</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>com.wordnik</groupId> <artifactId>swagger-annotations</artifactId> <version>1.3.11</version> </dependency> <!-- swagger-springmvc dependencies --> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>15.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.4.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.4.4</version> </dependency> <dependency> <groupId>com.fasterxml</groupId> <artifactId>classmate</artifactId> <version>1.1.0</version> </dependency>
使用的是这些jar包,而我下载的swagger是2.0版本以后的。所以总是不成功。于是我看了一下返回页面的json发现json里面的swagger版本都是1.X的版本,这里说一下1.X的版本返回的json中接口信息都是再apis这个字段里面,而2.X后是在paths下面。所以只有两种解决办法,一是让返回的json变成swagger2.X需要的样子,而是降低swaager的版本,可是如果降低swagger版本的话,低版本的可能功能不是很强悍。所以我才用了第一种方法。原来使用swagger2.X时使用的jar包完全不一样。具体据jar包如下:
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version></dependency><!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version></dependency>
然后只需要把下载的swagger包放到你项目能访问到的路径下就可以,然后访问其dist目录下的index.html文件即可,默认是swagger的示例页面,这里你可以在index.html中改成你要显示的页面,即将路径写成,index页面在项目中的路径。
阅读全文
0 0
- spring+sewwager在线文档生成器使用过程中遇到问题的分享
- imgbox使用过程中遇到的问题分享
- (七)java实现文档的在线浏览-使用过程中产生的问题
- VC6 使用过程中遇到的问题
- easyui使用过程中遇到的问题
- MyEclipse使用过程中遇到的问题
- 使用Qt过程中遇到的问题
- storm 使用过程中遇到的问题
- selenium使用过程中遇到的问题
- Ubuntu使用过程中遇到的问题
- Toolbar使用过程中遇到的问题
- xcode 使用过程中遇到的问题
- 使用Echarts过程中遇到的问题
- Ibatis使用过程中遇到的问题。
- Codis使用过程中遇到的问题
- 使用Espresso过程中遇到的问题
- ElasticSearch使用过程中遇到的问题
- pulseaudio使用过程中遇到的问题
- java-collection(迭代)
- ionic3开发过程中密码输入框随键盘的弹出,高度变小
- 《数据库技术与应用》读书笔记-未完成
- Python 开发者的 6 个必备库
- 【机房收费系统】——组合查询
- spring+sewwager在线文档生成器使用过程中遇到问题的分享
- DBCP object created 2017-12-01 08:48:35 by the following code was never closed
- Unity 项目管理与优化
- spring中的classpath代表哪个目录
- 第一个基于Spring-Boot框架的项目以及Java8新特新之stream流操作的简单细说
- Python使用OCR技术识别图片中的文字(入门篇)
- HashMap 的性能因子
- 去掉开头连续出现的某个字符
- Redis入门之 redis set集合的操作