Springfox Swagger 2 – Method paths(regex ("string")) does not work

so I’m writing a Docket, but when i call the paths method, there is the error "The method regex(String) is undefined for the type SwaggerConfig". My swagger dependencies all have the same version (3.0.0)

here is the code snippet I struggle with

package de.tut.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

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

public class SwaggerConfig {
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2)


>Solution :

You need to use


with PathSelectors being


Just using regex assumes that you want to use a method of the class you are in, which is what the compiler error is complaining about.

Leave a Reply