ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘;
Spring boot reports the following errors:
org.springframework.context.applicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java. lang.NullPointerException
After testing for a long time, it is found that the reason for swagger2:
Version 3.0.0 was originally used:
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
It is said that:
Reason: This is because Springfox uses path matching based on AntPathMatcher, while Spring Boot 2.6.X uses PathPatternMatcher.
Solution: Configure in application.properties: spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
After testing, no error was reported, but the search access http://localhost:8080/swagger-ui.html has 404
Final solution:
Switch the version of swagger2 and swaggerui to version 2.9.2
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
If it does not work like me, just add the following code in application.properties:
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
Problem solved!