出现原因分析
本人的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