SoFunction
Updated on 2025-04-07

Solutions for SpringBoot and Springfox (Swagger) version incompatible

1. Report an error message

: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is

2. Solution

Based on the error information and search results provided, this issue is often related to the integration of Spring Boot and Springfox (Swagger). Error messageFailed to start bean 'documentationPluginsBootstrapper'; nested exception is Indicates that during the Spring Boot application startup process,documentationPluginsBootstrapperThis bean cannot start normally because it encounters a null pointer exception (NullPointerException). This is usually due to path matching policy conflicts caused by incompatibility of Spring Boot and Springfox versions.

1. Modify the path matching strategy of Spring MVC

Modify the path matching strategy of Spring MVC: Springfox assumes that the path matching strategy of Spring MVC is ant-path-matcher, while the default matching strategy of Spring Boot 2.6 and above is path-pattern-matcher. You can solve this problem by adding the following configuration in or in the configuration file:

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

This allows you to change the path matching policy of Spring MVC toant-path-matcher, to be compatible with Springfox requirements.

2. Configurer

Configurer: You can create a configuration class and inheritWebMvcConfigurationSupport, then rewriteaddResourceHandlersMethod to solve the problem of static resource path:

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurationSupport {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        ("/**").addResourceLocations(
                "classpath:/static/");
        ("", "").addResourceLocations(
                "classpath:/META-INF/resources/");
        ("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
        (registry);
    }
}

This ensures that the static resources of Swagger can be loaded correctly.

3. Check dependencies

Check dependencies: Make sure that the correct Spring Boot Actuator dependencies are included in your project. If you are using Maven, you canAdd the following dependencies to the file:

<dependency>
    <groupId></groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

This helps ensuredocumentationPluginsBootstrapperbeans can be created correctly.

4. Reduce SpringBoot version

<parent>
  <groupId></groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.5.6</version>
  <relativePath/>
</parent>

This is the end of this article about the incompatible solutions of SpringBoot and Springfox (Swagger) versions. For more related content related to SpringBoot and Springfox versions, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!