首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Springboot 2.6.0 / Spring fox 3-无法启动bean 'documentationPluginsBootstrapper‘

问题概述

在使用Spring Boot 2.6.0和Spring Fox 3时,可能会遇到无法启动bean 'documentationPluginsBootstrapper'的问题。这个问题通常是由于版本兼容性问题引起的。

基础概念

  • Spring Boot: 一个用于简化Spring应用初始搭建以及开发过程的框架。
  • Spring Fox: 一个用于生成Swagger文档的库,可以方便地集成到Spring Boot应用中。

问题原因

Spring Fox 3与Spring Boot 2.6.0之间存在版本兼容性问题。Spring Fox 3依赖于一些在Spring Boot 2.6.0中已经被移除或修改的类和方法,导致无法启动。

解决方案

1. 使用兼容的版本组合

推荐使用Spring Boot 2.5.x版本与Spring Fox 3进行搭配。以下是具体的配置步骤:

2. 修改pom.xml

如果你使用的是Maven,可以在pom.xml中进行如下配置:

代码语言:txt
复制
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.6</version> <!-- 使用2.5.x版本 -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>3.0.0</version>
    </dependency>
</dependencies>

3. 配置Swagger

在Spring Boot应用的主类或配置类中添加Swagger配置:

代码语言:txt
复制
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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 SwaggerConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}

4. 启动应用

启动你的Spring Boot应用,检查是否能够正常启动并访问Swagger UI。

参考链接

通过以上步骤,你应该能够解决Spring Boot 2.6.0与Spring Fox 3之间的兼容性问题,并成功启动你的应用。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

springboot和swagger2冲突 Swagger-uiindex.html 404 解决

: Application run failed org.springframework.context.ApplicationContextException: Failed to start bean...$2.apply(DocumentationPluginsBootstrapper.java:138) ~[springfox-spring-web-2.9.2.jar:null] at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper...(DocumentationPluginsBootstrapper.java:96) ~[springfox-spring-web-2.9.2.jar:null] at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start...原因是在springboot2.6.0中将SpringMVC 默认路径匹配策略从AntPathMatcher 更改为PathPatternParser,导致出错。...(java项目fhadmin.cn) 可以在启动类上加上@EnableWebMvc注解或者在配置中切换为原先的AntPathMatcher spring.mvc.pathmatch.matching-strategy

1.3K20
  • 【WEB系列】高版本SpringBoot整合Swagger启动异常问题

    前言: Spring Boot 2.6.x 版本引入依赖 springfox-boot-starter (Swagger 3.0) 后,启动项目会报错: Failed to start bean ‘ documentationPluginsBootstrapper...原因: Springfox 假设 Spring MVC 的路径匹配策略是 ant-path-matcher,而 Spring Boot 2.6.x版本的默认匹配策略是 path-pattern-matcher...: mvc: pathmatch: matching-strategy: ant_path_matcher 需要注意的是:这种方法无法彻底解决问题,只有在不使用 Spring Boot...:(加在配置类里就可)Spring Boot 2.6.x整合Swagger启动失败报错问题解决(治标还治本)_toollong的博客-CSDN博客 @Bean public static BeanPostProcessor...‘documentationPluginsBootstrapper’ in spring data rest - Stack Overflow Spring Boot 2.6.x整合Swagger启动失败报错问题解决

    2.6K30

    几种Java热插拔技术实现总结

    例如Java EE项目中可能会因为某个Bean的定义或注入有问题,而导致整个应用跑不起来,而使用OSGI则不会有这种问题,顶多相关的几个Bundle无法启动。...Spring MVC时,通过DispatcherServlet启动的Bean与OSGI Bundle启动的Bean无法相互依赖,需要做特殊处理,后面文章中会有介绍。...Brick 介绍 “Spring-brick”,是一个可以动态扩展系统的框架,最早在2019年开始开发,该框架可以在SpringBoot项目上开发插件功能,开发插件就像开发独立应用一样,根据网站的介绍.../spring-brick-loader/target/classes started by apple in /Users/chenjujun/java-projects/springboot-plugin-framework-example...[Thread-1] c.g.s.example.listener.MyPluginListener : 插件[example-basic-1]启动成功 [Thread-1] d.s.w.p.DocumentationPluginsBootstrapper

    2.4K10

    已解决‘Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPoin

    已解决‘Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPointerException...在整合Spring Boot 2.7.x与Spring Cloud Alibaba 2021.0.5时,许多开发者遭遇了Failed to start bean ‘documentationPluginsBootstrapper...正文 问题背景 在整合Spring Boot 2.7.x与Spring Cloud Alibaba 2021.0.5的过程中,不少开发者都碰到了启动失败的问题。...其中最为常见的错误信息便是Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException...解决方案 修改路径匹配策略 为了解决这个问题,我们可以尝试更改Spring MVC的路径匹配策略。

    1.3K10

    SpringBoot从1.5.4升级到2.7.2问题总结

    问题 0、RestTemplate 循环依赖问题 编译不报错,启动报错,在springboot1.3版本中会默认提供一个RestTemplate的实例Bean,当在springboot1.4以及以后的版本中...Process finished with exit code 1 修改方式: @Lazy注解 1、hibernate-validator包下的类报错 Springboot从2.3以后,spring-boot-starter-web...如果能消除bean之间的依赖循环最好消除,如果实在改动太大,还有一种不推荐的处理方法,设置 spring.main.allow-circular-references=true 5、swagger错误:...Failed to start bean ‘documentationPluginsBootstrapper’ Application run failed org.springframework.boot.SpringApplication.reportFailure...(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.22.jar:5.3.22] 启动报了“Failed to start bean ‘documentationPluginsBootstrapper

    49610

    RabbitMQ六种队列模式之主题模式

    我们只能进行简单的广播,对应类型比较单一,使用direct后,消费者则可以进行一定程度的选择,但是direct 还是有局限性,路由不支持多个条件,简单理解就是direct交换机一旦与队列进行绑定那么就绑定了,无法像...(3)“quick.orange.fox”消息只会到第一队列, (4)“lazy.brown.fox”消息只会到第二个。...代码演示 本文是基于SpringBoot框架去集成的RabbitMQ,所以最好会SpringBoot基础,再跟着本文一起搭建主题队列Demo 创建一个简单的maven项目 ?...+ message); }} 启动消费者项目,项目启动后会自动消费消息 ? 队列中积压的消息被成功消费 ?...如“sunny.*”能与“sunny.sms”匹配,无法与“sunny.sms.yd”匹配;但是“sunny.#”能与上述两者匹配。

    1.4K40
    领券