🌷🍁 博主猫头虎(🐅🐾)带您 Go to New World✨🍁 🦄 博客首页——🐅🐾猫头虎的博客🎐 🐳 《面试题大全专栏》 🦕 文章图文并茂🦖生动形象🐅简单易学!欢迎大家来踩踩~🌺 🌊 《IDEA开发秘籍专栏》 🐾 学会IDEA常用操作,工作效率翻倍~💐 🌊 《100天精通Golang(基础入门篇)》 🐅 学会Golang语言,畅玩云原生,走遍大小厂~
🪁🍁 希望本文能够给您带来一定的帮助🌸文章粗浅,敬请批评指正!🐅🐾🍁🐥
📢 作者:猫头虎博主 🗓 日期:2023-09-06
当大家尝试将Spring Boot升级到2.7.x时,可能会遭遇一些与旧版本的依赖不兼容的问题。其中,一个常见的错误就是Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
。本文主要介绍如何解决这个问题。
09:50:14.151 [restartedMain] ERROR o.s.b.SpringApplication - [reportFailure,835] - Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:420)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at com.ruoyi.RuoYiApplication.main(RuoYiApplication.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.NullPointerException: null
at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56)
at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113)
at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89)
at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
从Spring Boot 2.5.x开始,Spring MVC的默认路径匹配策略已经变更为PathPattern
。之前版本使用的是AntPathMatcher
,这种变化可能与某些旧版本的依赖产生不兼容问题,例如旧版本的Springfox。
要解决上述问题,我们可以通过设置Spring MVC的路径匹配策略回到AntPathMatcher
。
在你的application.yml
或application.properties
中添加以下配置:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
确保你的pom.xml
中添加了正确版本的Spring Boot和Spring Cloud Alibaba的依赖。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.x</version>
...
</parent>
(⚠️ 注意: 这里只是一个简化的依赖样例,请根据实际情况进行调整。)
虽然技术持续地更新和进步,但这也带来了版本升级中的不兼容问题。希望通过这篇文章,大家能够轻松解决上述问题。如果你有任何问题或者建议,欢迎在评论区留言!
如果你觉得本文有帮助,请不吝点赞和分享!👍
======= ·