亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

knife4j+springboot3.4異常無法正確展示文檔

 更新時間:2025年01月13日 10:01:40   作者:立小言先森  
本文主要介紹了knife4j+springboot3.4異常無法正確展示文檔,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

場景復(fù)現(xiàn):

  • knife4j-openapi3-jakarta-spring-boot-starter版本
<!-- https://mvnrepository.com/artifact/com.github.xiaoymin/knife4j-openapi3-jakarta-spring-boot-starter -->
<dependency>
    <groupId>com.github.xiaoymin</groupId>
    <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
    <version>4.5.0</version>
</dependency>
  • 原來使用springboot3.3.5版本,先升級到3.4.0版本

  • 通過http://ip:port/doc.html訪問接口文檔發(fā)現(xiàn)訪問/v3/api-docs接口時報

Handler dispatch failed: java.lang.NoSuchMethodError: 'void org.springframework.web.method.ControllerAdviceBean.<init>(java.lang.Object)

通過分析異常日志發(fā)現(xiàn)是ControllerAdviceBean類報錯,在springboot3.3.5時spring-web版本是6.1.14,springboot3.4版本是6.2.0版本。

通過springboot全局異常捕獲堆棧信息發(fā)現(xiàn):

org.springdoc.core.service.GenericResponseService.lambda$getGenericMapResponse$8(GenericResponseService.java:702)

GenericResponseService類是在如下包:

<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-common -->
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-common</artifactId>
    <version>2.3.0</version>
</dependency>

GenericResponseService類的702行代碼如下(ControllerAdviceBean類使用一個參數(shù)的構(gòu)造函數(shù),但是報異常):

List<ControllerAdviceInfo> controllerAdviceInfosNotInThisBean = controllerAdviceInfos.stream()
					.filter(controllerAdviceInfo ->
							new ControllerAdviceBean(controllerAdviceInfo.getControllerAdvice()).isApplicableToBeanType(beanType))
					.filter(controllerAdviceInfo -> !beanType.equals(controllerAdviceInfo.getControllerAdvice().getClass()))
					.toList();

spring-web6.1.14版本中ControllerAdviceBean的構(gòu)造函數(shù):

	public ControllerAdviceBean(Object bean) {
		Assert.notNull(bean, "Bean must not be null");
		this.beanOrName = bean;
		this.isSingleton = true;
		this.resolvedBean = bean;
		this.beanType = ClassUtils.getUserClass(bean.getClass());
		this.beanTypePredicate = createBeanTypePredicate(this.beanType);
		this.beanFactory = null;
	}

spring-web6.2.0版本中ControllerAdviceBean的構(gòu)造函數(shù):

	public ControllerAdviceBean(String beanName, BeanFactory beanFactory, ControllerAdvice controllerAdvice) {
		Assert.hasText(beanName, "Bean name must contain text");
		Assert.notNull(beanFactory, "BeanFactory must not be null");
		Assert.isTrue(beanFactory.containsBean(beanName), () -> "BeanFactory [" + beanFactory +
				"] does not contain specified controller advice bean '" + beanName + "'");
		Assert.notNull(controllerAdvice, "ControllerAdvice must not be null");

		this.beanName = beanName;
		this.isSingleton = beanFactory.isSingleton(beanName);
		this.beanType = getBeanType(beanName, beanFactory);
		this.beanTypePredicate = createBeanTypePredicate(controllerAdvice);
		this.beanFactory = beanFactory;
	}

此類中的構(gòu)造函數(shù)已經(jīng)變更為4個,已經(jīng)不存在一個參數(shù)的構(gòu)造函數(shù)了。

  • springdoc-openapi-starter-common文檔當前已經(jīng)升級到2.7.0版本
<!-- https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-starter-common -->
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-common</artifactId>
    <version>2.7.0</version>
</dependency>

結(jié)論:期待knife4j-openapi3-jakarta-spring-boot-starter早日升級,兼容最新版本的spring;

開源SDK:https://github.com/mingyang66/spring-parent

到此這篇關(guān)于knife4j+springboot3.4異常無法正確展示文檔的文章就介紹到這了,更多相關(guān)knife4j springboot3.4異常無法展示內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • WebFlux 服務(wù)編排使用優(yōu)勢詳解

    WebFlux 服務(wù)編排使用優(yōu)勢詳解

    這篇文章主要為大家介紹了WebFlux 服務(wù)編排使用優(yōu)勢示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-05-05
  • 用Rational Rose逆向工程(java)生成類圖(教程和錯誤解決)

    用Rational Rose逆向工程(java)生成類圖(教程和錯誤解決)

    Rational Rose有個很方便的功能,將項目中的JAVA代碼自動轉(zhuǎn)換成UML類圖
    2013-02-02
  • Java多線程之FutureTask的介紹及使用

    Java多線程之FutureTask的介紹及使用

    之前介紹了線程池相關(guān)的對象,Runable Callable與Future,下面介紹FutureTask的作用,它的特性是怎樣的呢,需要的朋友可以參考下
    2021-06-06
  • Java中處理各類配置文件的7種工具使用詳解

    Java中處理各類配置文件的7種工具使用詳解

    在Java應(yīng)用開發(fā)中,選擇合適的配置文件格式和處理工具對于提高開發(fā)效率和系統(tǒng)靈活性至關(guān)重要,本文為大家整理了7個有效的工具,需要的可以了解下
    2025-05-05
  • java多線程之wait(),notify(),notifyAll()的詳解分析

    java多線程之wait(),notify(),notifyAll()的詳解分析

    本篇文章是對java多線程 wait(),notify(),notifyAll()進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06
  • Java軟件設(shè)計模式之適配器模式詳解

    Java軟件設(shè)計模式之適配器模式詳解

    這篇文章主要介紹了Java軟件設(shè)計模式之適配器模式詳解,適配器模式可分為對象適配器和類適配器兩種,在對象適配器模式中,適配器與適配者之間是關(guān)聯(lián)關(guān)系;在類適配器模式中,適配器與適配者之間是繼承(或?qū)崿F(xiàn))關(guān)系,需要的朋友可以參考下
    2023-07-07
  • Spring中最常用的注解之一@Autowired詳解

    Spring中最常用的注解之一@Autowired詳解

    本文講解了Spring中最常用的注解之一@Autowired, 平時我們可能都是使用屬性注入的,但是后續(xù)建議大家慢慢改變習(xí)慣,使用構(gòu)造器注入。同時也講解了這個注解背后的實現(xiàn)原理,需要的朋友可以參考下
    2023-01-01
  • @RequestBody的使用詳解

    @RequestBody的使用詳解

    這篇文章主要介紹了@RequestBody的使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • java實現(xiàn)Redisson看門狗機制

    java實現(xiàn)Redisson看門狗機制

    redission看門狗機制是解決分布式鎖的續(xù)約問題,本文就來詳細的介紹一下java實現(xiàn)Redisson看門狗機制,具有一定的參考價值,感興趣的可以了解一下
    2024-09-09
  • SpringCloud+RocketMQ實現(xiàn)分布式事務(wù)的實踐

    SpringCloud+RocketMQ實現(xiàn)分布式事務(wù)的實踐

    分布式事務(wù)已經(jīng)成為了我們的經(jīng)常使用的。所以我們來一步一步的實現(xiàn)基于RocketMQ的分布式事務(wù)。感興趣的可以了解一下
    2021-10-10

最新評論