首页 > 其他分享 >【已解决】Swagger配置问题—Failed to start bean ‘documentationPluginsBootstrapper‘

【已解决】Swagger配置问题—Failed to start bean ‘documentationPluginsBootstrapper‘

时间:2024-05-30 14:58:29浏览次数:9  
标签:application swagger java start swagger2 Failed bean ui springfox

项目场景:

swagger-demo

编写SwaggerConfig.java后运行SwaggerDemoApplication.java不能成功


问题描述

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
访问http://localhost:8080/swagger-ui.html
在这里插入图片描述

当前SpringBoot版本为2.7.13(pom.xml文件中)

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.13</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

原因分析:

当前SpringBoot版本和swagger2导入的相关依赖不兼容

当前添加的swagger相关依赖(pom.xml文件中)

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

解决方案:

在application.properties中添加一行配置

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

重新运行SwaggerDemoApplication.java再访问http://localhost:8080/swagger-ui.html
在这里插入图片描述

标签:application,swagger,java,start,swagger2,Failed,bean,ui,springfox
From: https://blog.csdn.net/2401_83329143/article/details/138858363

相关文章

  • Spring Bean实例化:从源码窥探生命之源
    1.引言在Spring框架中,Bean的生命周期是一个至关重要的概念,它涉及了Bean的创建、初始化、使用以及销毁等多个阶段。其中,Bean的实例化作为生命周期的起点,具有举足轻重的地位。以下将对Spring中Bean的实例化过程进行深度解析,结合源码分析,提供更深入的理解。2.Bean实例化的......
  • GD32 使用ST-Link进行调试出现Error:Flash Download Failed-“Cortex-M3“ 解决方案
    项目场景:原来一直使用STM32,最近有个项目发项工程师打板采用的是GD32,外部引脚是一一对应的,STM32的各种下载工具和方法也是基本相同的。问题描述`前期就是库函数和芯片包要改成GD32的。前期工作都完成了,剩下最后一公里,就是下载程序。在MDK5中,采用STLINK,选好芯片型号,准备下载,但出现了Error:FlashDow......
  • request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has
    换华为的,否则会出问题:cnpmconfgsetregistryhttps://mirrors.huaweicloud.com/repository/npm/npmERR!codeCERT_HAS_EXPIREDnpmERR!errnoCERT_HAS_EXPIREDnpmERR!requesttohttps://registry.npm.taobao.org/cnpmfailed,reason:certificatehasexpirednpmER......
  • mysql实现oracle的start with递归查询
    oracle查询语句selectdept_codefrom表名startwithdept_code='41311046430000001'connectbyPRIORid=PARENT_ID结果如下:改为mysql查询,实用函数实现selectsd.*from (select*from表名)sd, (select@pid:=(selectidfrom表名wheredept_code='4131......
  • Spring Aware接口:揭秘Bean生命周期中的“先知”角色与源码剖析
    1.引言在Spring框架中,Bean的生命周期是一个复杂而精细的过程,涉及到Bean的创建、初始化、属性注入以及销毁等多个阶段。为了增强Bean与Spring容器之间的交互能力,Spring提供了一系列Aware接口,这些接口允许Bean在生命周期的不同阶段获取Spring容器的特定资源或信息,从而实现了......
  • Spring Bean的“魔法”之旅:深入剖析属性填充的艺术
    1.引言在Spring框架中,Bean的生命周期是一个复杂而精妙的过程,而属性填充(PropertyPopulation)作为这一过程中的关键阶段,对于Bean的初始化和功能实现至关重要。为了更生动地展示SpringBean属性填充的机制,将从全局视角出发,结合源码分析、更多具体实例以及创意性思考,对这一过......
  • Error creating bean with name ‘dataSource‘ defined in class path resource解决
    报错信息ERROR3592—[restartedMain]o.s.boot.SpringApplication:Applicationrunfailedorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname‘dataSource’definedinclasspathresource[org/springframework/boot/autoconfi......
  • SpringBoot升级到3.2.0报错Invalid value type for attribute ‘factoryBeanObjectTyp
    1现象SpringBoot由3.1.0升级为3.2.0时报的错:直接debug进入该行,看到报错的bean信息:看到是MyBatis出问题。2处理MyBatis先想到mybatis-spring版本较低导致。大家应该都用的MyBatisPlus,其实可暂缓升级3.2,等待一段时间,升级MyBatisPlus即可,目前MyBatisPlus的mybatis-spring......
  • 踩坑记录: nohup: failed to run command ‘java‘: No such file or directory
    执行一个shell脚本直接在终端可以执行但是在云效流水线上就会出现这个问题 先查看一下java-version 已经安装好了的话还是出现这个问题解决方案1:在执行Java包的前面加上这个 source/etc/profile还是不可以的话 解决方案2:先查看自己的jdk安装路径 which......
  • pnpm安装依赖出现ELIFECYCLE  Command failed with exit code 1 Build failed
    这种情况一般是安装了nvm的情况下会出现,错误提示一般如下Progress:resolved1713,reused1633,downloaded0,added1632,donenode_modules/.pnpm/[email protected]/node_modules/core-js:Runningpostinstallscript,donein118msnode_modules/.pnpm/[email protected]/nod......