《SpringBoot系列》SpringBoot[Failed to start bean ‘documentationPluginsBootstrapper’]

在尝试将Swagger集成到SpringBoot 2.6.4应用时遇到'documentationPluginsBootstrapper'启动失败的问题,博客指出该问题是由于SpringMVC匹配策略变更导致。通过在application.yml中设置`spring.mvc.pathmatch.matching-strategy: ant_path_matcher`来解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DATA数据猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值