SpringBoot[Failed to start bean ‘documentationPluginsBootstrapper’]
1. 添加Swagger依赖
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
2. 添加Swagger配置[application.yml]
springfox:
documentation:
swagger-ui:
enabled: true
3. 启动即报错
org.springframework.context.ApplicationContextException:
Failed to start bean 'documentationPluginsBootstrapper';
nested exception is java.lang.NullPointerException
4.查找原因
根据查找,很多提到是版本的问题,于是换了不同版本的Swagger依赖
还有的说是因为swagger依赖google的guava的版本问题
经过尝试后,并没有解决我的问题
最后发现了如下这个博客
最终解决问题参考来源
5. 解决问题
因为我使用的SpringBoot的版本是2.6.4,根据上述博主的说法,是因为SpringBoot中SpringMVC的默认策略从ANT_PATH_MATCHER
改成了PATH_PATTERN_PARSER所以就有错误了,解决方案如下:
在application.yml配置文件中添加如下:
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher