Failed to start bean 'documentationPluginsBootstrapper' Spring boot Swagger implementation using Spring Fox?
Asked Answered
I

2

10

I am using springfox-boot-starter dependency for swagger UI in my spring boot application but when I try to run the application I am getting below error

    Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;)Ljava/util/Optional;
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:184)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157)
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:885)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)

my config file:


 @Bean
 public Docket productApi() {
        
     return new Docket(DocumentationType.SWAGGER_2)
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.swagger.demo.controller"))
        .paths(regex("/student.*"))
        .build()
        .enableUrlTemplating(true)
        .produces(DEFAULT_PRODUCES_AND_CONSUMES)
        .consumes(DEFAULT_PRODUCES_AND_CONSUMES)
        .apiInfo(apiEndPointsInfo());
    }

private ApiInfo apiEndPointsInfo() {

    return new ApiInfoBuilder()
            .title("demo")
            .description("demo")
            .version("1.0")
            .build();
} 

Below is the dependency which I am using. pom.xml file:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
    
<dependencies>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>
</dependencies>

Why I am getting above error I don't get anything. Any help would be highly appreciated. Thanks in advance.

Isoagglutinin answered 21/9, 2020 at 12:0 Comment(2)
Does this answer your question? Failed to start bean 'documentationPluginsBootstrapper' in spring data restCuzco
Any update on this? Facing the same issue. Is any fix available?Streusel
L
26

I had a similar issue and found the solution here. Basically you have to include in the file application.properties the following configuration:

spring.mvc.pathmatch.matching-strategy=ant-path-matcher

As it seems Spring Boot 2+ set as default the PathPathern-based matcher, while Spring Fox expects the Ant-based matcher. The problem with this solution is that you cannot use Spring Actuator, since it uses PathPattern based URL matching. In this case, check this Spring Fox issue.

Lettering answered 23/11, 2021 at 20:6 Comment(0)
C
1
SwaggerConfig.java 


@Configuration  
//Enable Swagger  
@EnableSwagger2  
public class SwaggerConfig   
{  
//creating bean  
    
@Bean  
public Docket api()  
{  
//creating constructor of Docket class that accepts parameter DocumentationType  
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("com.example.demo.controller")).paths(PathSelectors.regex("/api.*")).build();  
}  
}  


And Application.properties file :

spring.mvc.pathmatch.matching-strategy=ant-path-matcher
Compete answered 2/10, 2022 at 15:37 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Fondue

© 2022 - 2024 — McMap. All rights reserved.