8

Upgrading Springboot version- 2.7.0 ext { springBootVersion = '2.7.0' wsdl2javaVersion='0.10' cxfVersion='3.4.3' }

Cloud Version: ext { set('springCloudVersion', '2021.0.3') }

Springfox: //swagger compile "io.springfox:springfox-swagger2:2.9.2" compile "io.springfox:springfox-swagger-ui:2.9.2"

Getting Error: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerExceptionclass

Any lead is really appreciate to fix this issue.

Dibya
  • 81
  • 1
  • 1
  • 3
  • 2
    Incompatible swagger version. – M. Deinum Jun 02 '22 at 12:04
  • Does this answer your question? [Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'](https://stackoverflow.com/questions/70036953/springboot-2-6-0-spring-fox-3-failed-to-start-bean-documentationpluginsboot) – Henning Jun 04 '22 at 16:18

4 Answers4

4

In the application.properties

spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER
meher
  • 61
  • 1
  • 9
2

If you are using the spring-boot version 2.7.x, springfox, and the actuator use this dependency (I don't know will it work for your case, at the time I'm doing this, version of spring-boot 2.7.1)

  1. In pom.xml

     <!-- API documentation. Refer the link http://springfox.github.io/springfox/docs/2.7.0/#introduction -->
     <dependency>
         <groupId>io.springfox</groupId>
         <artifactId>springfox-swagger2</artifactId>
         <version>2.7.0</version>
     </dependency>
    
  2. Then in the SwaggerConfig configuration class

     /* .pathMapping("/") can resolve the conflict between actuator and springfox */
     @Bean
     public Docket api() {
         return new Docket(DocumentationType.SWAGGER_2)
             .select()
             .apis(RequestHandlerSelectors.any())
             .paths(PathSelectors.any())
             .build()
             .pathMapping("/");
     }
    
  3. Then

if you're using the application.properties

spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER

if you're using the application.yml

    spring:
      #Use this to befriend spring-boot-starter-actuator & springfox-boot-starter
       mvc:
         pathmatch:
           matching-strategy: ANT_PATH_MATCHER
0

Add this bean to your swagger configuration

@Bean
    public WebMvcRequestHandlerProvider webMvcRequestHandlerProvider(Optional<ServletContext> servletContext, HandlerMethodResolver methodResolver, List<RequestMappingInfoHandlerMapping> handlerMappings) {
        handlerMappings = handlerMappings.stream().filter(rh -> rh.getClass().getName().contains("RequestMapping")).toList();
        return new WebMvcRequestHandlerProvider(servletContext, methodResolver, handlerMappings);
    }

and make sure you used DocumentationType.OAS_30 in your config

also, add this in your proerties file:

spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER

this worked for me, BUT now I can access only the endpoints directly, and not the swagger page

Octavia
  • 198
  • 1
  • 13
0

After several hours of search:

java -version

is also important. I have JDK 11.smth, so I had to downgrade Spring to 2.5.3 - even 2.6.0 gave the same issue. Now it works with both Swagger 2 and OAS3.

17-th java is ok with suggestions above.