【精选】Springboot ✚ Swagger各版本整理 |
您所在的位置:网站首页 › springboot版本冲突 › 【精选】Springboot ✚ Swagger各版本整理 |
Springboot ✚ Swagger各版本整理
swagger配置变化原因:Swagger版本1、Swagger 2.x 版本springboot 2.5.6 ✚ swagger 2.6.1~2.9.2配置属下
2、Swagger 3.x 版本springboot 2.5.6 ✚ swagger 3.0.0配置属下springboot 2.6.5 ✚ swagger 3.0.0配置属下
Knife4j 版本Knife4j 3.0.3 ✚ Springboot2.7.1
swagger配置变化原因:
SpringBoot处理映射匹配的默认策略发生变化 请求路径与 Spring MVC 处理映射匹配的默认策略已从AntPathMatcher更改为PathPatternParser。你可以设置spring.mvc.pathmatch.matching-strategy为ant-path-matcher来改变它。 springboot 2.6.0之前 public static class Pathmatch { private MatchingStrategy matchingStrategy = MatchingStrategy.ANT_PATH_MATCHER; }springboot2.6.0之后 public static class Pathmatch { private MatchingStrategy matchingStrategy = MatchingStrategy.PATH_PATTERN_PARSER; }如果升级springboot到2.6之后,需要设置spring.mvc.pathmatch.matching-strategy=ant-path-matcher来兼容Swagger2 2.Swagger升级 Swagger版本 1、Swagger 2.x 版本 swagger访问路径3.0.0之前http://127.0.0.1:8080/swagger-ui.html3.0.0之后http://127.0.0.1:8080/swagger-ui/index.html springboot 2.5.6 ✚ swagger 2.6.1~2.9.2配置属下 org.springframework.boot spring-boot-starter-parent 2.5.6 io.springfox springfox-boot-starter 2.6.1 2.7.0 2.8.0 2.9.2 都可以只需要在启动类上加 @EnableSwagger2 注解即可 访问地址:http://127.0.0.1:8080/swagger-ui.html 2、Swagger 3.x 版本 springboot 2.5.6 ✚ swagger 3.0.0配置属下 org.springframework.boot spring-boot-starter-parent 2.5.6 io.springfox springfox-boot-starter 3.0.0只需要在启动类上加 @EnableSwagger2注解即可 访问地址:http://127.0.0.1:8080/swagger-ui/index.html springboot 2.6.5 ✚ swagger 3.0.0配置属下 org.springframework.boot spring-boot-starter-parent 2.6.5 io.springfox springfox-boot-starter 3.0.0application.yml 或applicaiton.properties 中添 必须 加如下配置 spring: mvc: pathmatch: matching-strategy: ant_path_matcher只需要在启动类上加 @EnableSwagger2 注解即可 访问地址:http://127.0.0.1:8080/swagger-ui/index.html Knife4j 版本访问地址:http://127.0.0.1:8080/doc.html,访问方式和之前的保持一致,如果项目中配置拦截器等,需要放开doc.html静态资源 版本说明SpringBoot配置注解增强功能1.9.6蓝色皮肤风格,增加更多后端模块@EnableSwagger2不支持2.0~2.0.5Ui重写,蓝色背景变成黑色,底层依赖的springfox框架版本是2.9.2@EnableSwagger2开启方式@EnableKnife4j2.0.6~底层springfox框架版本升级知2.10.5,OpenAPI规范是v2大于等于2.2.x (2.6.0之后需要需要设置spring.mvc.pathmatch.matching-strategy =ant-path-matcher)@EnableSwagger2WebMvc开启方式knife4j.enable=true默认不开启3.0~底层依赖springfox框架版本升级至3.0.3,OpenAPI规范是v3大于等于2.2.x(2.6.0之后需要需要设置spring.mvc.pathmatch.matching-strategy =ant-path-matcher)写不写都可以开启方式knife4j.enable=true默认不开启 Knife4j 3.0.3 ✚ Springboot2.7.1 org.springframework.boot spring-boot-starter-parent 2.7.1 com.github.xiaoymin knife4j-spring-boot-starter 3.0.3 spring: mvc: pathmatch: matching-strategy: ant_path_matcherKnife4j 3.0.3 增强功能配置 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |