问题:
全新SpringBoot项目配置Swagger
1,无法启动项目,报异常:Failed to start bean ‘documentationPluginsBootstrapper’
Failed to start bean ‘documentationPluginsBootstrapper’
2,localhost:8080/swagger-ui.html 无法显示
解决办法:
1,application.yml中添加配置(解决异常问题):
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
原因是在springboot2.6.0中将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错,解决办法是切换回原先的AntPathMatcher
本人SpringBoot版本2.6.7
2,在pom.xml中将Swagger依赖的版本从最新的3.0.0,降为2.9.2(解决swagger-ui不显示问题):
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>