Swagger-创新互联
1:Swagger概念
3:简单使用
分享名称:Swagger-创新互联
分享地址:http://pwwzsj.com/article/ehoip.html
个人理解:
Swagger是前后端分离时代的产物。在大型项目开发的过程中,由于前后端相互独立,后端人员只要负责写api接口给前端人员使用,前端人员使用后端提供的接口获取数据用于展示。可是如果需求变更,前后端无法及时交流就会导致交流问题,延缓项目开发进度。swagger就是为解决这个问题而产生,它可以集成在后端中及时更新,同时前端人员可以使用数据测试,得到后端的数据,如果不符合,可以及时交流。
创建Springboot项目=web项目
https://start.spring.io/
pox导入springfox 和 swagger-ui
io.springfox
springfox-swagger22.9.2 io.springfox
springfox-swagger-ui2.9.2
配置开启swagger
@Configuration
@EnableSwagger2 //开启swagger
public class SwaggerConfig {
}
访问
配置完成后重启项目,访问: http://localhost:8080/swagger-ui.html
如果项目报错和访问页面无法打开:
在application.properties或者yaml(yaml要符合其格式)中配置如下: spring.mvc.pathmatch.matching-strategy=ant_path_matcher

swagger的其他配置百度即可,非常简单
使用
在后端中,只要配置映射,我们打开SwaggerUI的时候就会生成对应的测试文档



你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
分享名称:Swagger-创新互联
分享地址:http://pwwzsj.com/article/ehoip.html