出现原因分析
本人的springboot版本是最新的2.6.1,swagger版本是2.9.2,按着网上的步骤进行环境配置,但在运行时却会出现Failed to start bean ‘documentationPluginsBootstrapper’的问题,在排查了多方原因后,我发现是springboot的版本更新,导致的swagger2的异常
解决方法
(本人的解决方法)在yml中新增配置
application.yml
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
原因是在springboot2.6.0中将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错,解决办法是切换回原先的AntPathMatcher
(简单粗暴法)修改springboot的版本
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
降到2.6.0以下的应该就可以了
(网上其他人的解决方法)新增依赖
pom.xml
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version>
</dependency>
看网上有些人新增了这个依赖就可以正常使用了,这个问题要具体看swagger2的版本,最新版的可能需要更新最新版的guava
在尝试使用SpringBoot 2.6.1和Swagger2 2.9.2进行整合时,遇到'Failed to start bean 'documentationPluginsBootstrapper''的问题。原因是SpringBoot 2.6.0开始,默认路径匹配策略从AntPathMatcher变为PathPatternParser。解决方法包括:在application.yml中设置spring.mvc.pathmatch.matching-strategy为ant_path_matcher,或将SpringBoot版本回退到2.6.0以下。另外,一些情况下添加Guava 25.1-jre依赖也可能解决问题。
1万+

被折叠的 条评论
为什么被折叠?



