kandi background
Explore Kits

springfox | Automated JSON API documentation for API's built with Spring | REST library

 by   springfox Java Version: 3.0.0 License: Apache-2.0

 by   springfox Java Version: 3.0.0 License: Apache-2.0

Download this library from

kandi X-RAY | springfox Summary

springfox is a Java library typically used in Web Services, REST, Spring Boot, Spring, Swagger applications. springfox has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub, Maven.
For more information on this project visit the Springfox Website or http://springfox.github.io/springfox/.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • springfox has a highly active ecosystem.
  • It has 5505 star(s) with 1493 fork(s). There are 274 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 278 open issues and 3153 have been closed. On average issues are closed in 262 days. There are 62 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of springfox is 3.0.0
springfox Support
Best in #REST
Average in #REST
springfox Support
Best in #REST
Average in #REST

quality kandi Quality

  • springfox has 0 bugs and 0 code smells.
springfox Quality
Best in #REST
Average in #REST
springfox Quality
Best in #REST
Average in #REST

securitySecurity

  • springfox has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • springfox code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
springfox Security
Best in #REST
Average in #REST
springfox Security
Best in #REST
Average in #REST

license License

  • springfox is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
springfox License
Best in #REST
Average in #REST
springfox License
Best in #REST
Average in #REST

buildReuse

  • springfox releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • springfox saves you 43301 person hours of effort in developing the same functionality from scratch.
  • It has 51146 lines of code, 5776 functions and 953 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
springfox Reuse
Best in #REST
Average in #REST
springfox Reuse
Best in #REST
Average in #REST
Top functions reviewed by kandi - BETA

kandi has reviewed springfox and discovered the below as its top functions. This is intended to give you an instant insight into springfox implemented functionality, and help decide if they suit your requirements.

  • Initialize response messages .
  • Merges the given model branch .
  • Expands all fields of the expansion context .
  • Return the corresponding data type for the given data type .
  • Resolve the given expression .
  • Map the given scheme to a Spring documentation scheme .
  • Creates an instance of ValidRangeValues based on the given min and maxima .
  • Apply return type override .
  • Finds the list of properties that should be included in the given member .
  • Gets the form parameters .

springfox Key Features

Automated JSON API documentation for API's built with Spring

Getting Started

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

Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'

copy iconCopydownload iconDownload
@SpringBootApplication
@EnableSwagger2
public class Application {
-----------------------
// build.gradle
implementation "org.springdoc:springdoc-openapi-ui:1.6.4"
@SpringBootApplication
@OpenAPIDefinition
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}
-----------------------
// build.gradle
implementation "org.springdoc:springdoc-openapi-ui:1.6.4"
@SpringBootApplication
@OpenAPIDefinition
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}
-----------------------
@Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
        List<ExposableEndpoint<?>> allEndpoints = new ArrayList();
        Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
        allEndpoints.addAll(webEndpoints);
        allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
        allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
        String basePath = webEndpointProperties.getBasePath();
        EndpointMapping endpointMapping = new EndpointMapping(basePath);
        boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
        return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
    }


private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
        return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
    }
-----------------------
@EnableSwagger2
@SpringBootApplication
@EnableSwagger2
public class Application {}
-----------------------
@EnableWebMvc
@SpringBootApplication
public class MyApp {
    public static void main(String[] args) {
        SpringApplication.run(MyApp.class);
    }
}
-----------------------
@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);
    }

Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue

copy iconCopydownload iconDownload
mvn dependency:tree
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
-----------------------
mvn dependency:tree
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
-----------------------
spring.main.web-application-type=reactive

Use main Gradle project to define all dependencies versions

copy iconCopydownload iconDownload
dependencyResolutionManagement {
    versionCatalogs {
        libs {
            library('spring-cloud-bom', 'org.springframework.cloud:spring-cloud-dependencies:2021.0.1')
            library('spring-cloud-starter', 'org.springframework.cloud', 'spring-cloud-starter-netflix-eureka-client').withoutVersion()
            library('spring-boot-starter-validation', 'org.springframework.boot', 'spring-boot-starter-validation').withoutVersion()
            library('spring-boot-starter-test', 'org.springframework.boot', 'spring-boot-starter-test').withoutVersion()
            library('threetenbp', 'org.threeten:threetenbp:1.5.1')
            library('spring-boot-starter-actuator', 'org.springframework.boot', 'spring-boot-starter-actuator').withoutVersion()
            library('lombok', 'org.projectlombok:lombok:1.18.22')
            library('springfox-boot-starter', 'io.springfox:springfox-boot-starter:3.0.0')
            library('spring-boot-starter-hateoas', 'org.springframework.boot:spring-boot-starter-hateoas:2.6.3')
            library('hysterix-core', 'com.netflix.hystrix:hystrix-core:1.5.18')
            library('spring-security-core', 'org.springframework.security:spring-security-core:5.6.1')
            library('junit-jupiter-api', 'org.junit.jupiter:junit-jupiter-api:5.8.2')
            library('junit-jupiter-engine', 'org.junit.jupiter:junit-jupiter-engine:5.8.2')
        }
    }
}
dependencies {
    implementation libs.spring.cloud.starter
    implementation libs.spring.boot.starter.validation
    testImplementation libs.spring.boot.starter.test
    implementation libs.threetenbp
    implementation libs.spring.boot.starter.actuator
    // Lombok
    compileOnly libs.lombok
    annotationProcessor libs.lombok
    testCompileOnly libs.lombok
    testAnnotationProcessor libs.lombok
    // Swagger
    implementation libs.springfox.boot.starter
    implementation libs.spring.boot.starter.hateoas
    implementation libs.hysterix.core
    implementation libs.spring.security.core
    testImplementation libs.junit.jupiter.api
    testRuntimeOnly libs.junit.jupiter.engine
}
dependencyManagement {
    imports {
        mavenBom libs.spring.cloud.bom.get().toString()
    }
    resolutionStrategy {
        cacheDynamicVersionsFor 0, "seconds"
        cacheChangingModulesFor 0, "seconds"
    }
}
-----------------------
dependencyResolutionManagement {
    versionCatalogs {
        libs {
            library('spring-cloud-bom', 'org.springframework.cloud:spring-cloud-dependencies:2021.0.1')
            library('spring-cloud-starter', 'org.springframework.cloud', 'spring-cloud-starter-netflix-eureka-client').withoutVersion()
            library('spring-boot-starter-validation', 'org.springframework.boot', 'spring-boot-starter-validation').withoutVersion()
            library('spring-boot-starter-test', 'org.springframework.boot', 'spring-boot-starter-test').withoutVersion()
            library('threetenbp', 'org.threeten:threetenbp:1.5.1')
            library('spring-boot-starter-actuator', 'org.springframework.boot', 'spring-boot-starter-actuator').withoutVersion()
            library('lombok', 'org.projectlombok:lombok:1.18.22')
            library('springfox-boot-starter', 'io.springfox:springfox-boot-starter:3.0.0')
            library('spring-boot-starter-hateoas', 'org.springframework.boot:spring-boot-starter-hateoas:2.6.3')
            library('hysterix-core', 'com.netflix.hystrix:hystrix-core:1.5.18')
            library('spring-security-core', 'org.springframework.security:spring-security-core:5.6.1')
            library('junit-jupiter-api', 'org.junit.jupiter:junit-jupiter-api:5.8.2')
            library('junit-jupiter-engine', 'org.junit.jupiter:junit-jupiter-engine:5.8.2')
        }
    }
}
dependencies {
    implementation libs.spring.cloud.starter
    implementation libs.spring.boot.starter.validation
    testImplementation libs.spring.boot.starter.test
    implementation libs.threetenbp
    implementation libs.spring.boot.starter.actuator
    // Lombok
    compileOnly libs.lombok
    annotationProcessor libs.lombok
    testCompileOnly libs.lombok
    testAnnotationProcessor libs.lombok
    // Swagger
    implementation libs.springfox.boot.starter
    implementation libs.spring.boot.starter.hateoas
    implementation libs.hysterix.core
    implementation libs.spring.security.core
    testImplementation libs.junit.jupiter.api
    testRuntimeOnly libs.junit.jupiter.engine
}
dependencyManagement {
    imports {
        mavenBom libs.spring.cloud.bom.get().toString()
    }
    resolutionStrategy {
        cacheDynamicVersionsFor 0, "seconds"
        cacheChangingModulesFor 0, "seconds"
    }
}
-----------------------
dependencyResolutionManagement {
    versionCatalogs {
        libs {
            library('spring-cloud-bom', 'org.springframework.cloud:spring-cloud-dependencies:2021.0.1')
            library('spring-cloud-starter', 'org.springframework.cloud', 'spring-cloud-starter-netflix-eureka-client').withoutVersion()
            library('spring-boot-starter-validation', 'org.springframework.boot', 'spring-boot-starter-validation').withoutVersion()
            library('spring-boot-starter-test', 'org.springframework.boot', 'spring-boot-starter-test').withoutVersion()
            library('threetenbp', 'org.threeten:threetenbp:1.5.1')
            library('spring-boot-starter-actuator', 'org.springframework.boot', 'spring-boot-starter-actuator').withoutVersion()
            library('lombok', 'org.projectlombok:lombok:1.18.22')
            library('springfox-boot-starter', 'io.springfox:springfox-boot-starter:3.0.0')
            library('spring-boot-starter-hateoas', 'org.springframework.boot:spring-boot-starter-hateoas:2.6.3')
            library('hysterix-core', 'com.netflix.hystrix:hystrix-core:1.5.18')
            library('spring-security-core', 'org.springframework.security:spring-security-core:5.6.1')
            library('junit-jupiter-api', 'org.junit.jupiter:junit-jupiter-api:5.8.2')
            library('junit-jupiter-engine', 'org.junit.jupiter:junit-jupiter-engine:5.8.2')
        }
    }
}
dependencies {
    implementation libs.spring.cloud.starter
    implementation libs.spring.boot.starter.validation
    testImplementation libs.spring.boot.starter.test
    implementation libs.threetenbp
    implementation libs.spring.boot.starter.actuator
    // Lombok
    compileOnly libs.lombok
    annotationProcessor libs.lombok
    testCompileOnly libs.lombok
    testAnnotationProcessor libs.lombok
    // Swagger
    implementation libs.springfox.boot.starter
    implementation libs.spring.boot.starter.hateoas
    implementation libs.hysterix.core
    implementation libs.spring.security.core
    testImplementation libs.junit.jupiter.api
    testRuntimeOnly libs.junit.jupiter.engine
}
dependencyManagement {
    imports {
        mavenBom libs.spring.cloud.bom.get().toString()
    }
    resolutionStrategy {
        cacheDynamicVersionsFor 0, "seconds"
        cacheChangingModulesFor 0, "seconds"
    }
}

Springfox 3.0.0 is not working with Spring Boot 2.6.0

copy iconCopydownload iconDownload
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>
-----------------------
@Bean
public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
    return new BeanPostProcessor() {

        @Override
        public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
            if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
                customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
            }
            return bean;
        }

        private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
            List<T> copy = mappings.stream()
                .filter(mapping -> mapping.getPatternParser() == null)
                .collect(Collectors.toList());
            mappings.clear();
            mappings.addAll(copy);
        }

        @SuppressWarnings("unchecked")
        private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
            try {
                Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
                field.setAccessible(true);
                return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
            } catch (IllegalArgumentException | IllegalAccessException e) {
                throw new IllegalStateException(e);
            }
        }
    };
}
-----------------------
public class SpringFoxConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build().apiInfo(getApiInfo());
    }
    
    private ApiInfo getApiInfo() {
        return new ApiInfo(
                "Api Usuarios",
                "prueba global logic",
                "1",
                "TERMS OF SERVICE URL",
                new Contact("Gabriel Hernández","URL","gabriel.hernandez.u@gmail.com"),
                "LICENSE",
                "LICENSE URL",
                Collections.emptyList()
        );
    }
    
    @Bean
    public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
        return new BeanPostProcessor() {

            @Override
            public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
                if (bean instanceof WebMvcRequestHandlerProvider ) {
                    customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
                }
                return bean;
            }

            private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
                List<T> copy = mappings.stream()
                    .filter(mapping -> mapping.getPatternParser() == null)
                    .collect(Collectors.toList());
                mappings.clear();
                mappings.addAll(copy);
            }

            @SuppressWarnings("unchecked")
            private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
                try {
                    Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
                    field.setAccessible(true);
                    return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    throw new IllegalStateException(e);
                }
            }
        };
    }    
}
-----------------------
@EnableWebMvc
@SpringBootApplication
public class MyApp {
    public static void main(String[] args) {
        SpringApplication.run(MyApp.class);
    }
}
-----------------------
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
-----------------------
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
-----------------------
@Bean
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier, EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties, WebEndpointProperties webEndpointProperties, Environment environment) {
        List<ExposableEndpoint<?>> allEndpoints = new ArrayList<>();
        Collection<ExposableWebEndpoint> webEndpoints = webEndpointsSupplier.getEndpoints();
        allEndpoints.addAll(webEndpoints);
        allEndpoints.addAll(servletEndpointsSupplier.getEndpoints());
        allEndpoints.addAll(controllerEndpointsSupplier.getEndpoints());
        String basePath = webEndpointProperties.getBasePath();
        EndpointMapping endpointMapping = new EndpointMapping(basePath);
        boolean shouldRegisterLinksMapping = this.shouldRegisterLinksMapping(webEndpointProperties, environment, basePath);
        return new WebMvcEndpointHandlerMapping(endpointMapping, webEndpoints, endpointMediaTypes, corsProperties.toCorsConfiguration(), new EndpointLinksResolver(allEndpoints, basePath), shouldRegisterLinksMapping, null);
    }


private boolean shouldRegisterLinksMapping(WebEndpointProperties webEndpointProperties, Environment environment, String basePath) {
        return webEndpointProperties.getDiscovery().isEnabled() && (StringUtils.hasText(basePath) || ManagementPortType.get(environment).equals(ManagementPortType.DIFFERENT));
    }

Version conflicts while using spring boot azure blob storage

copy iconCopydownload iconDownload
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.5</version>
</parent>

Failed to load ApplicationContext for a java based config test

copy iconCopydownload iconDownload
@Configuration
public class ExternalConfig {
    private static final String SECRET_ID_EVEN_TOKEN = "evenToken";

    @Bean
    public EvenClient webClient( AWSSecretsManagerService awsSecretsManagerService,
                         @Value("${even.url}") String url) {

        String token = awsSecretsManagerService.getSecretValue().get(SECRET_ID_EVEN_TOKEN);

        WebClient webClient = WebClient.builder()
                .exchangeStrategies(ExchangeStrategies.builder()
                        .codecs(configurer -> configurer
                                .defaultCodecs()
                                .maxInMemorySize(100 * 1024 * 1024) // default is 256 KB (262144 B), changed it to 100MB
                        ).build())
                .baseUrl(url)
                .defaultHeaders(h -> h.setBearerAuth(token))
                .build();
        return new EvenClient(webClient);
    }
}
-----------------------
 @org.springframework.boot.test.mock.mockito.MockBean
 private ExternalConfig externalConfig;

How do I control tag order in Springdoc OpenAPI 3.0?

copy iconCopydownload iconDownload
springdoc.swagger-ui.tagsSorter: alpha
springdoc.writer-with-order-by-keys: true
-----------------------
springdoc.swagger-ui.tagsSorter: alpha
springdoc.writer-with-order-by-keys: true

Spring-Boot upgrade to 2.6.2 gives error at runtime - BeanCreationException

copy iconCopydownload iconDownload
Caused by: java.lang.NoClassDefFoundError:
org/springframework/boot/configurationprocessor/json/JSONException at...
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-configuration-processor</artifactId>
  <optional>true</optional>
</dependency>
-----------------------
Caused by: java.lang.NoClassDefFoundError:
org/springframework/boot/configurationprocessor/json/JSONException at...
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-configuration-processor</artifactId>
  <optional>true</optional>
</dependency>

connect spring boot to swagger

copy iconCopydownload iconDownload
...
@Bean //Don't forget the @Bean annotation
public Docket customImplementation(){
   return new Docket()
         .apiInfo(apiInfo());
         //... more options available
...

Replace @PathVariable object with ID only for Springdoc

copy iconCopydownload iconDownload
@Component
public class InstanceParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer {
    @Override
    public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) {
        if (Instance.class.equals(methodParameter.getParameterType()) && methodParameter.getParameterAnnotation(PathVariable.class) != null) {
            parameterModel.setName("id"); // if you need to change the name  ...
            parameterModel.setSchema(new StringSchema());
        }
        return parameterModel;
    }
}

Community Discussions

Trending Discussions on springfox
  • Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
  • Springfox Type javax.servlet.http.HttpServletRequest not present
  • Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue
  • Use main Gradle project to define all dependencies versions
  • Springfox 3.0.0 is not working with Spring Boot 2.6.0
  • Version conflicts while using spring boot azure blob storage
  • Failed to load ApplicationContext for a java based config test
  • How do I control tag order in Springdoc OpenAPI 3.0?
  • Spring-Boot upgrade to 2.6.2 gives error at runtime - BeanCreationException
  • FeignClient logs printing two configured Interceptor called, this is confusion to identify which one is actual at runtime
Trending Discussions on springfox

QUESTION

Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'

Asked 2022-Mar-25 at 06:14

I'm trying to initiate a Springboot project using Open Jdk 15, Springboot 2.6.0, Springfox 3. We are working on a project that replaced Netty as the webserver and used Jetty instead because we do not need a non-blocking environment.

In the code we depend primarily on Reactor API (Flux, Mono), so we can not remove org.springframework.boot:spring-boot-starter-webflux dependencies.

I replicated the problem that we have in a new project.: https://github.com/jvacaq/spring-fox.

I figured out that these lines in our build.gradle file are the origin of the problem.

compile("org.springframework.boot:spring-boot-starter-web") {
   exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")

Here is the build.gradle file:

plugins {
    id 'org.springframework.boot' version '2.6.0'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web") {
        exclude module: "spring-boot-starter-tomcat"
    }
    compile("org.springframework.boot:spring-boot-starter-jetty")
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
    implementation "io.springfox:springfox-boot-starter:3.0.0"
}

test {
    useJUnitPlatform()
}

I issued the command gradle clean bootrun. The result is this error:

 gradle clean bootrun                                                                                                                                                                                                               

> Task :bootRun FAILED

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.0)

2021-11-19 09:41:06.665  INFO 16666 --- [           main] c.e.springfox.SpringFoxApplication       : Starting SpringFoxApplication using Java 15.0.2 on advance-Inspiron-5379 with PID 16666 (/home/advance/projects/spring-fox/build/classes/java/main started by advance in /home/advance/projects/spring-fox)
2021-11-19 09:41:06.666  INFO 16666 --- [           main] c.e.springfox.SpringFoxApplication       : No active profile set, falling back to default profiles: default
2021-11-19 09:41:07.294  INFO 16666 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @1132ms to org.eclipse.jetty.util.log.Slf4jLog
2021-11-19 09:41:07.396  INFO 16666 --- [           main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8080
2021-11-19 09:41:07.398  INFO 16666 --- [           main] org.eclipse.jetty.server.Server          : jetty-9.4.44.v20210927; built: 2021-09-27T23:02:44.612Z; git: 8da83308eeca865e495e53ef315a249d63ba9332; jvm 15.0.2+7-27
2021-11-19 09:41:07.417  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring embedded WebApplicationContext
2021-11-19 09:41:07.417  INFO 16666 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 713 ms
2021-11-19 09:41:07.474  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : DefaultSessionIdManager workerName=node0
2021-11-19 09:41:07.474  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : No SessionScavenger set, using defaults
2021-11-19 09:41:07.475  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : node0 Scavenging every 660000ms
2021-11-19 09:41:07.480  INFO 16666 --- [           main] o.e.jetty.server.handler.ContextHandler  : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@6aa3bfc{application,/,[file:///tmp/jetty-docbase.8080.2024342829220941812/, jar:file:/home/advance/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/3.0.0/1e665fbe22148f7c36fa8a08e515a0047cd4390b/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],AVAILABLE}
2021-11-19 09:41:07.480  INFO 16666 --- [           main] org.eclipse.jetty.server.Server          : Started @1318ms
2021-11-19 09:41:07.920  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-11-19 09:41:07.920  INFO 16666 --- [           main] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-11-19 09:41:07.921  INFO 16666 --- [           main] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2021-11-19 09:41:07.931  INFO 16666 --- [           main] o.e.jetty.server.AbstractConnector       : Started ServerConnector@2643d762{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2021-11-19 09:41:07.932  INFO 16666 --- [           main] o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on port(s) 8080 (http/1.1) with context path '/'
2021-11-19 09:41:07.934  WARN 16666 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
2021-11-19 09:41:07.949  INFO 16666 --- [           main] o.e.jetty.server.AbstractConnector       : Stopped ServerConnector@2643d762{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2021-11-19 09:41:07.950  INFO 16666 --- [           main] org.eclipse.jetty.server.session         : node0 Stopped scavenging
2021-11-19 09:41:07.951  INFO 16666 --- [           main] o.e.j.s.h.ContextHandler.application     : Destroying Spring FrameworkServlet 'dispatcherServlet'
2021-11-19 09:41:07.951  INFO 16666 --- [           main] o.e.jetty.server.handler.ContextHandler  : Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext@6aa3bfc{application,/,[file:///tmp/jetty-docbase.8080.2024342829220941812/, jar:file:/home/advance/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/3.0.0/1e665fbe22148f7c36fa8a08e515a0047cd4390b/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],STOPPED}
2021-11-19 09:41:07.958  INFO 16666 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-11-19 09:41:07.970 ERROR 16666 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.13.jar:5.3.13]
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.13.jar:5.3.13]
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.13.jar:5.3.13]
        at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.13.jar:5.3.13]
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.13.jar:5.3.13]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) ~[spring-context-5.3.13.jar:5.3.13]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.13.jar:5.3.13]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.0.jar:2.6.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-2.6.0.jar:2.6.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.6.0.jar:2.6.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.0.jar:2.6.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.0.jar:2.6.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.0.jar:2.6.0]
        at com.example.springfox.SpringFoxApplication.main(SpringFoxApplication.java:10) ~[main/:na]
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
        at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
        at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113) ~[springfox-core-3.0.0.jar:3.0.0]
        at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89) ~[springfox-spi-3.0.0.jar:3.0.0]
        at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469) ~[na:na]
        at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) ~[na:na]
        at java.base/java.util.TimSort.sort(TimSort.java:220) ~[na:na]
        at java.base/java.util.Arrays.sort(Arrays.java:1306) ~[na:na]
        at java.base/java.util.ArrayList.sort(ArrayList.java:1721) ~[na:na]
        at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:392) ~[na:na]
        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
        at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
        at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81) ~[springfox-spring-webmvc-3.0.0.jar:3.0.0]
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na]
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[na:na]
        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107) ~[springfox-spring-web-3.0.0.jar:3.0.0]
        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91) ~[springfox-spring-web-3.0.0.jar:3.0.0]
        at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82) ~[springfox-spring-web-3.0.0.jar:3.0.0]
        at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100) ~[springfox-spring-web-3.0.0.jar:3.0.0]
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.13.jar:5.3.13]
        ... 14 common frames omitted


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/home/advance/.sdkman/candidates/java/15.0.2-open/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
5 actionable tasks: 5 executed

Does anyone have an idea how to solve it?

ANSWER

Answered 2022-Feb-08 at 12:36

This problem's caused by a bug in Springfox. It's making an assumption about how Spring MVC is set up that doesn't always hold true. Specifically, it's assuming that MVC's path matching will use the Ant-based path matcher and not the PathPattern-based matcher. PathPattern-based matching has been an option for some time now and is the default as of Spring Boot 2.6.

As described in Spring Boot 2.6's release notes, you can restore the configuration that Springfox assumes will be used by setting spring.mvc.pathmatch.matching-strategy to ant-path-matcher in your application.properties file. Note that this will only work if you are not using Spring Boot's Actuator. The Actuator always uses PathPattern-based parsing, irrespective of the configured matching-strategy. A change to Springfox will be required if you want to use it with the Actuator in Spring Boot 2.6 and later.

Source https://stackoverflow.com/questions/70036953

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install springfox

NOTE: Would love feedback to make this better. NOTE: Would love feedback to make this better. NOTE: Would love feedback to make this experience better.
Remove explicit dependencies on springfox-swagger2
Remove any @EnableSwagger2... annotations
Add the springfox-boot-starter dependency
Springfox 3.x removes dependencies on guava and other 3rd party libraries (not zero dep yet! depends on spring plugin and open api libraries for annotations and models) so if you used guava predicates/functions those will need to transition to java 8 function interfaces.
Remove explicit dependencies on springfox-swagger2
Remove the @EnableSwagger2 annotations
Add the springfox-boot-starter dependency
Springfox 3.x removes dependencies on guava and other 3rd party libraries (not zero dep yet! depends on spring plugin and open api libraries for annotations and models) so if you used guava predicates/functions those will need to transition to java 8 function interfaces
If you are using WebMvc but you don't use the @EnableWebMvc annotation yet, add this annotation.
Remove explicit dependencies on springfox-swagger2
Add @EnableOpenApi for open API (and @EnableSwagger2WebMvc or @EnableSwagger2WebFlux for older versions)
Added the springfox-oas library
Springfox 3.x removes dependencies on guava and other 3rd party libraries (not zero dep yet! depends on spring plugin and open api libraries for annotations and models) so if you used guava predicates/functions those will need to transition to java 8 function interfaces

Support

Reference DocumentationExamples repositoryContribution GuidelinesCore contributorsDevelopment and contribution guidelinesChange logDevelopment EnvironmentRelease Instructions

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.