栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

springboot读取bootstrap配置及knife4j版本兼容性问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

springboot读取bootstrap配置及knife4j版本兼容性问题

文章目录
  • 项目框架说明
  • 连环坑
    • 问题一:springboot项目无法读取bootstrap.yml配置
    • 问题二:启动报错,springboot与springcloud版本不匹配
    • 问题三:启动报错Failed to start bean 'documentationPluginsBootstrapper'
      • 另一种解决方案:修改springmvc的路径匹配策略 - 待验证
  • 版本匹配
    • springboot与bootstrap(springcloud)
    • 最终版本方案
  • 后记:不要轻易升级版本

    因某些特殊原因,需要使用springboot项目读取bootstrap.yml中配置,然而添加bootstrap依赖包后,又引发了springboot、springcloud与knife4j版本匹配的问题=_=|| 这真是一个环。。。
    写篇文章,来记录下连环坑的‘快乐’心路历程~

项目框架说明

项目背景说明:
SpringBoot 2.2.5.RELEASE
knife4j 3.0.3

连环坑
  • 引入bootstrap启动前配置后,启动失败
  • 按照错误升级springboot版本至2.6.6后,启动失败
  • knife4j与springboot版本不兼容,需降springboot版本
  • 尝试三者的版本匹配
问题一:springboot项目无法读取bootstrap.yml配置

参考文献:springboot项目启动报错无法识别bootstrap.yml配置问题

出现此问题的原因:SpringBoot项目,只会识别application. *配置文件,并不会自动识别bootstrap.yml
解决方案:在pom.xml中添加了bootstrap启动器依赖


    org.springframework.cloud
    spring-cloud-starter-bootstrap
    3.1.1

问题二:启动报错,springboot与springcloud版本不匹配

错误如下:

Spring Boot [2.2.5.RELEASE] is not compatible with this Spring Cloud release train

Action:

Consider applying the following actions:

- Change Spring Boot version to one of the following versions [2.6.x, 2.7.x] .

没办法,按照错误升级springboot版本吧(初步尝试2.6.6)

问题三:启动报错Failed to start bean ‘documentationPluginsBootstrapper’

错误如下:

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'

在网上查找了下相关问题,参考文献:org.springframework.context.ApplicationContextException的解决办法,发现是knife4j(swagger)与springboot版本不匹配,得降低springboot版本!!!

另一种解决方案:修改springmvc的路径匹配策略 - 待验证
因为Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher。
#解决:在application.properties里配置
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
版本匹配 springboot与bootstrap(springcloud)
bootstrap(springcloud)版本springboot版本
3.0.1及3.0.0[2.3.x, 2.4.x]
3.0.3[2.4.x, 2.5.x]
3.1.1[2.6.x, 2.7.x]
最终版本方案

SpringBoot 2.4.13 + SpringCloud 3.0.1 + knife4j 3.0.3 终于可以了!!!!

后记:不要轻易升级版本

血的教训啊,想着knife4j升级一个大版本看下新特性,结果引发了一系列问题~
ps:自己对于框架的知识还是不够清楚啊,得努力学习喽~

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/985983.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号