SpringBoot项目中启动Swagger如果报以下错误,可以通过两种方案解决:
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

这种错误是因为SpringBoot版本和Swagger版本不匹配导致的,博主Swagger和Swagger-UI用的都是Springfox 2.9.2的,SpringBoot是Idea中创建时自动提供的2.6.2的,Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher,两种解决方案如下:
1、修改SpringBoot的版本,去使用早期版本即可解决这个问题;
2、yml配置文件中添加配置:ant_path_matcherspring: mvc: pathmatch: matching-strategy: ant_path_matcher。

版权声明:本文为threelifeadv原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。