Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

        
AI编程,程序员挑战年入30~100万高级指南 - 职业规划
SpringBoot+SpringSecurity+Vue权限系统高级实战课程        

IDEA永久激活

Java微信小程序电商实战课程(SpringBoot+VUe)

     

AI人工智能学习大礼包

     

PyCharm永久激活

66套java实战课程无套路领取

     

Cursor+Claude AI编程 1天快速上手视频教程

     
当前位置: 主页 > Java文档 > Java基础相关 >

swagger学习资料 PDF 下载


时间:2020-10-22 11:39来源:http://www.java1234.com 作者:转载  侵权举报
swagger学习资料 PDF 下载
失效链接处理
swagger学习资料 PDF 下载


本站整理下载:
提取码:4a20 
 
 
相关截图:
 
主要内容:


1. 导包
swagger2
ui
2. SpringBoot集成Swagger
配置 Swagger(configer)
3. 注解
注意:在正式发布的时候出于安全考虑,要关闭Swagger,重要的是节省
内存
导包
1. maven官网搜索 springfox-swagger
这两个都需要下载
l https: imvnrepository.com/artifact/io.springfox/s pringfox-swagger-ui h <dependency> 12
springBoot集成
1. 开启Swagger
使用 @EnableSwagger2 注解开启(Swagger是老版,Swagger2是新
版)
开启后不需要配置其他,有默认值
访问 localhost:8080/swagger-ui.html页面进行访问 api 文档
<groupId>io.springfox ɟgroupId> <artifactId>springfox-swagger-ui ɟartifactId> <version>2.9.2 ɟversion> ɟdependency> l https: imvnrepository.com/artifact/io.springfox/s pringfox-swagger2 h <dependency> <groupId>io.springfox ɟgroupId> <artifactId>springfox-swagger2 ɟartifactId> <version>2.9.2 ɟversion> ɟdependency> 3456789101112131415
使用异常
1. 访问异常
使用Swagger并且配置拦截器时,一定要在日志中查看Swagger有哪写请
求,并且放开Swagger的请求
报错一:页面提示或报错404
Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://exa mple.org/api/v2/api-docs then the base url is htt p://example.org/api/. Please enter the location manually:
原因:拦截器没有全部开放,需要开放一下三个请求
 端口号错误
".*swagger-ui.html.*", "/lyy/webjars.*", ".*swagger.*" 123
错误二,页面提示没有指定版本号

 

------分隔线----------------------------


锋哥推荐