swagger的使用说明
swagger的使用说明
对于swagger的使用,实际上,我们不是单独使用,都是以springfox整合swagger的方式来使用的。以下是两个springfox版本的使用说明。
1 springfox2整合swagger
-
访问URL: http://host:port/context-path/swagger-ui.html
eg. http://localhost:8888/swagger-ui.html -
maven依赖
<dependency> <groupId>com.spring4all</groupId> <artifactId>swagger-spring-boot-starter</artifactId> <version>1.9.0.RELEASE</version> </dependency>
以上依赖,实际上内部包含了以下2个swagger依赖:
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency>
2 springfox3整合swagger
-
访问URL:
旧URL也能用:http://host:port/context-path/swagger-ui.html
还添加了新的URL:http://host:port/context-path/swagger-ui/
另一个新的URL:http://host:port/context-path/swagger-ui/index.html
eg1. http://localhost:8888/swagger-ui/
eg2. http://localhost:8888/swagger-ui/index.html -
文档接口:
旧的也能用:http://localhost:8888/v2/api-docs
还添加了新的:http://localhost:8888/v3/api-docs -
maven依赖
<!-- swagger3--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> <!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 --> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> <version>1.6.2</version> </dependency>
以上依赖,实际上内部包含了以下2个swagger依赖:
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>3.0.0</version> <scope>compile</scope> </dependency>
分类:
swagger
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理