SpringBoot入门到精通-三步整合knife4j

knife4j的比较好看

Knife4j的前身是swagger-bootstrap-ui,前身swagger-bootstrap-ui是一个纯swagger-uiui皮肤项目

一开始项目初衷是为了写一个增强版本的swagger的前端ui,但是随着项目的发展,面对越来越多的个性化需求,不得不编写后端Java代码以满足新的需求,在swagger-bootstrap-ui的1.8.5~1.9.6版本之间,采用的是后端Java代码和Ui都混合在一个Jar包里面的方式提供给开发者使用.这种方式虽说对于集成swagger来说很方便,只需要引入jar包即可,但是在微服务架构下显得有些臃肿。

因此,项目正式更名为knife4j,取名knife4j是希望她能像一把匕首一样小巧,轻量,并且功能强悍,更名也是希望把她做成一个为Swagger接口文档服务的通用性解决方案,不仅仅只是专注于前端Ui前端.

swagger-bootstrap-ui的所有特性都会集中在knife4j-spring-ui包中,并且后续也会满足开发者更多的个性化需求.

主要的变化是,项目的相关类包路径更换为com.github.xiaoymin.knife4j前缀,开发者使用增强注解时需要替换包路径

后端Java代码和ui包分离为多个模块的jar包,以面对在目前微服务架构下,更加方便的使用增强文档注解(使用SpringCloud微服务项目,只需要在网关层集成UI的jar包即可,因此分离前后端)

knife4j沿用swagger-bootstrap-ui的版本号,第1个版本从1.9.6开始,关于使用方法,请参考文档

引入依赖包

<!--lombok插件-->
<dependency>
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
springboot2.7整合knife4j4.3是指在Springboot 2.7版本中使用Knife4j 4.3进行API文档的生成和管理。具体步骤如下: 1.在pom.xml文件中添加Knife4j的依赖: ``` <dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-spring-boot-starter</artifactId> <version>4.3.0</version> </dependency> ``` 2.在application.yml文件中进行配置: ``` spring: profiles: active: dev application: name: demo-knife4j-openapi3 servlet: multipart: max-file-size: 10MB max-request-size: 100MB resources: static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 serialization: fail-on-empty-beans: false indent-output: true write-dates-as-timestamps: false write-null-map-values: false write-empty-json-arrays: false write-enums-using-to-string: true http: encoding: charset: UTF-8 enabled: true servlet: session: timeout: 30m datasource: url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource druid: initial-size: 5 min-idle: 5 max-active: 20 test-on-borrow: true validation-query: SELECT 1 FROM DUAL filters: stat,wall,log4j connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 jpa: show-sql: true hibernate: ddl-auto: update naming: physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl server: port: 8080 tomcat: uri-encoding: UTF-8 max-threads: 200 min-spare-threads: 10 max-http-header-size: 1048576 accesslog: enabled: true directory: logs prefix: access_log suffix: .log rotate: true pattern: common knife4j: title: demo-knife4j-openapi3 description: demo-knife4j-openapi3 version: 1.0.0 contact: name: demo-knife4j-openapi3 url: http://localhost:8080/doc.html email: demo-knife4j-[email protected] license: name: Apache License 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html terms-of-service-url: http://localhost:8080/doc.html host: localhost:8080 packages: com.example.demo ``` 3.在启动类上添加@EnableKnife4j注解: ``` @SpringBootApplication @EnableKnife4j public class DemoKnife4jOpenapi3Application { public static void main(String[] args) { SpringApplication.run(DemoKnife4jOpenapi3Application.class, args); } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

未来AI编程

共鸣===鼓励 打赏您随意

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值