报错信息如下:
org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
在spring boot web项目中写了一个controller方法,可以正常完成请求,项目结构如下
pom.xml配置如下:本项目是实战练习swagger,因此增加了一个Swagger的配置类,内容如下: pom.xml加入swagger的依赖: 然后启动项目,报错信息如下:yy_parent com.example 0.0.1-SNAPSHOT 4.0.0 service pom service_user service_hosp com.example service_util 0.0.1-SNAPSHOT com.example model 0.0.1-SNAPSHOT org.springframework.boot spring-boot-starter-web com.baomidou mybatis-plus-boot-starter mysql mysql-connector-java org.springframework.boot spring-boot-devtools true org.springframework.boot spring-boot-maven-plugin src/main/java ***.properties ***.yml ***.xml false
org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
查看了项目代码,没有非空后,在网上找到项目为什么报空指针异常 原因:Springfox使用的路径匹配基于AntPathMatcher,而Spring Boot 2.6.X使用的是PathPatternMatcher。解决办法是在application文件中写入:
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER



