简单说knife4j就swagger的升级版API文档的一个框架,可是用起来比swagger方便多了,UI更加丰富。html
简略的说一下,基础环境搭建可参考:SpringBoot2.x集成Swagger2java
这里我说一下主要配置区别:web
环境说明:api
新增 knife4j.version:2.0.2app
@Configuration @EnableSwagger2 @EnableKnife4j @Import(BeanValidatorPluginsConfiguration.class) public class SwaggerConfig { @Bean(value = "createRestApi") public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(new ApiInfoBuilder() //标题 .title("项目API接口") //版本信息 .version("1.0") //描述消息 .description("接口列表") .contact(new Contact("项目API接口","localhost:8801/auth/doc.html","xxxx@qq.com")) .license("mamba") // .licenseUrl("http://www.xxxx.com/") .build()) //最终调用接口后会和paths拼接在一块儿 .pathMapping("/") .select() //包路径 .apis(RequestHandlerSelectors.basePackage("com.mamba.platform.cli.auth.controller")) //过滤的接口 .paths(PathSelectors.any()) .build(); } }
.yml配置框架
swagger: enable: true knife4j: production: true
http://ip:port/doc.htmlsvg