完整的错误信息: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
Spring Boot 引入 Swagger-ui 版本冲突问题会报以上错误。
我的 pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
解决办法:
在 application.properties 中设置spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
或者
@EnableWebMvc
@EnableSwagger2
@Component
public class SwaggersConfig {
}
另一种解决方法就是将org.springframework.boot
版本降低为 2.5.X