首页 > 基础资料 博客日记
Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPointerEx
2024-03-02 21:00:05基础资料围观174次
Java资料网推荐Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPointerEx这篇文章给大家,欢迎收藏Java资料网享受知识的乐趣
这是因为springboot的版本和Springfox-Swagge的版本不兼容,可能会报错如下所示:
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
因为Springfox 使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X以上使用的是PathPatternMatcher。
解决方案
降低Spring Boot 版本到2.6.x以下版本
比如比较经典的版本组合
SpringBoot版本不降级解决方案
这里需要改一些配置
application.yml中添加如下配置
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
SwaggerConfig类解决兼容问题
/**
* 增加如下配置可解决Spring Boot 与Swagger 不兼容问题
* @param webEndpointsSupplier
* @param servletEndpointsSupplier
* @param controllerEndpointsSupplier
* @param endpointMediaTypes
* @param corsProperties
* @param webEndpointProperties
* @param environment
* @return
*/
@Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
List<ExposableEndpoint<?>> allEndpoints = new ArrayList();
Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
allEndpoints.addAll(webEndpoints);
allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
String basePath = webEndpointProperties.getBasePath();
EndpointMapping endpointMapping = new EndpointMapping(basePath);
boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
}
private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
}
文章来源:https://blog.csdn.net/m0_37450089/article/details/131647365
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!
标签:
相关文章
最新发布
- java.lang.reflect.InaccessibleObjectException: Unable to make final void java.lang.Throwable.setCaus
- Java毕业设计:基于Java在线中药网上销售商城系统毕业设计源代码作品和开题报告
- html2canvas + jspdf 纯前端HTML导出PDF的实现与问题
- SpringBoot+Docker +Nginx 部署前后端项目
- 前几天顺手改的一个安卓启动器,已经获得40多颗星了
- 建行支付对接(H5)
- Java毕业设计:Java杭州城市文化展示系统毕业设计源代码作品和开题报告
- Java中的位图和布隆过滤器(如果想知道Java中有关位图和布隆过滤器的知识点,那么只看这一篇就足够了!)
- 少小白学前端——leaflet篇(Javascript 地图库)
- IDEA更改远程git仓库地址