设计师建站网站,网站建设款计入哪个会计分录,wordpress判断ie6,大连龙彩科技的网站在谁家做knife4j集合化postman
01 knife4j的介绍
基于 JavaMVC的集成框架swagger的进一步强化#xff0c;在原有通过注释就能生成文档的前身swagger-bootstrap-ui之上#xff0c;增加了postman的测试功能#xff0c;优化了文档的UI界面#xff0c;在测试api接口的方面有了极大的进…knife4j集合化postman
01 knife4j的介绍
基于 JavaMVC的集成框架swagger的进一步强化在原有通过注释就能生成文档的前身swagger-bootstrap-ui之上增加了postman的测试功能优化了文档的UI界面在测试api接口的方面有了极大的进步
02 前期准备
1.引入依赖
dependencygroupIdcom.github.xiaoymin/groupIdartifactIdknife4j-spring-boot-starter/artifactIdversion2.0.9/version
/dependency2.配置yml文件
server:port: 8080servlet:context-path: /web# 配置数据源
spring:mvc:pathmatch:matching-strategy: ant_path_matcher3.引入配置类
Configuration
EnableSwagger2WebMvc
public class SwaggerConfig {Beanpublic Docket docket() {return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage(com.example.demo.controller))//扫描的包路径.build();}private ApiInfo apiInfo() {return new ApiInfoBuilder().title(接口文档的标题)//文档标题.version(1.0.0)//文档版本说明.description(文档的描述)//文档的描述.build();}}03 测试
1.测试的实体类
ApiModel(类别实体类)//用于标记实体类
Data
AllArgsConstructor
NoArgsConstructor
public class Category {ApiModelProperty(类别编码)//用于标记实体类属性作用private Long categoryId;private String categoryName;private String categoryPicture1;private String categoryPicture2;
}2.测试的控制类
Api(tags 类别模块)//用于标记整个控制模块
RestController
RequestMapping(/category)
public class CategoryController {//用于标记该路径value是标记该路径名notes是详细的解释ApiOperation(value 查询类别,notes 根据类别id查询类别 )GetMapping(/select)public Category select(Long categoryId){Category category new Category();return category;}ApiImplicitParam(name categoryId,value 类别编号,required true)//用于标记返回值同样的name是标记名字value是解释PostMapping(/post)public Category post(Long categoryId){Category category new Category();return category;}ApiImplicitParams({ApiImplicitParam(name categoryId,value 类别编号,required true),ApiImplicitParam(name categoryName,value 类别名字,required true),ApiImplicitParam(name categoryPicture1,value 类别图片,required false),})//批量标记返回值PostMapping(/set)public Category set(Long categoryId,String categoryName,String categoryPicture1){Category category new Category();return category;}GetMapping(/delete)public Category delete(){Category category new Category();return category;}
}3.访问生成的文档
项目启动后访问localhost端口号/根路径/doc.html 4.API接口测试
在类别模块中选择需要测试的接口 5.调试选项
在调试选项中就可以像postman一样使用了