Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The method apis(java.util.function.Predicate<springfox.documentation.RequestHandler>) in the type ApiSelectorBuilder is not applicable

@Bean .api method is giving me below error. I have added Swagger config class with @Beans as usual.

The method apis(java.util.function.Predicate<springfox.documentation.RequestHandler>) in the type ApiSelectorBuilder is not applicable for the arguments (com.google.common.base.Predicate<springfox.documentation.RequestHandler>)

My Config class is below:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SpringFoxConfig extends WebMvcConfigurationSupport {                                    
    @Bean
    public Docket api() { 
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage(                                            
                    "package com.sample.controller;"))
                .paths(PathSelectors.any())
                .build();
                                                
    }
}
like image 898
Ana Avatar asked Jul 31 '20 14:07

Ana


2 Answers

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>

I tried these dependencies and the error did disappear.

like image 149
BsGhaz Avatar answered Oct 25 '22 10:10

BsGhaz


Remove the following dependency:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>

use the following:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
like image 26
Deb Avatar answered Oct 25 '22 11:10

Deb