實體類序列化報錯:Caused by: java.lang.NoSuchMethodException: com.xx.PoJo$Item.<init>()

原實體類代碼

@EqualsAndHashCode(callSuper = true)
@Data
public class Pojo extends BaseBean {private static final long serialVersionUID = -4291335073882689552L;@ApiModelProperty("")private Integer id;......private List<Item> list;@AllArgsConstructor@Datapublic static class Item{......}
}

報錯信息

org.springframework.beans.InvalidPropertyException: Invalid property 'list[0]' of bean class [com.xx.PoJo]: Illegal attempt to get property 'list' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'list' of bean class [com.xx.PoJo]: Could not instantiate property type [com.xx.PoJo$Item] to auto-grow nested property path; nested exception is java.lang.NoSuchMethodException: com.xx.PoJo$Item.<init>()at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:712)at org.springframework.beans.AbstractNestablePropertyAccessor.getNestedPropertyAccessor(AbstractNestablePropertyAccessor.java:843)at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyAccessorForPropertyPath(AbstractNestablePropertyAccessor.java:820)at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:256)at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:889)at org.springframework.validation.DataBinder.doBind(DataBinder.java:780)at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:207)at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:129)
......
Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'list' of bean class [com.xx.PoJo]: Could not instantiate property type [com.xx.PoJo] to auto-grow nested property path; nested exception is java.lang.NoSuchMethodException: com.xx.PoJo$Item.<init>()at org.springframework.beans.AbstractNestablePropertyAccessor.newValue(AbstractNestablePropertyAccessor.java:923)at org.springframework.beans.AbstractNestablePropertyAccessor.growCollectionIfNecessary(AbstractNestablePropertyAccessor.java:790)at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:659)... 57 common frames omitted
Caused by: java.lang.NoSuchMethodException: com.senshun.pay.bus.model.FuiouCloseUserNotify$BankItem.<init>()at java.base/java.lang.Class.getConstructor0(Class.java:3349)at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2553)at org.springframework.beans.AbstractNestablePropertyAccessor.newValue(AbstractNestablePropertyAccessor.java:914)... 59 common frames omitted
10:03:40.648 [http-nio-8904-exec-10] WARN  o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [org.springframework.beans.InvalidPropertyException: Invalid property 'list[0]' of bean class [com.xx.PoJo]: Illegal attempt to get property 'list' threw exception; nested exception is org.springframework.beans.NullValueInNestedPathException: Invalid property 'list' of bean class [com.xx.PoJo]: Could not instantiate property type [com.xx.PoJo$Item] to auto-grow nested property path; nested exception is java.lang.NoSuchMethodException: com.xx.PoJo$Item.<init>()]

原因及解決辦法

com.xx.PoJo$Item.<init>()

意思就是實體類Pojo中Item實體類沒有無參構造方法。

在Item實體類添加上無參構造方法或者加上@NoArgsConstructor注解即可。

@EqualsAndHashCode(callSuper = true)
@Data
public class Pojo extends BaseBean {private static final long serialVersionUID = -4291335073882689552L;@ApiModelProperty("")private Integer id;......private List<Item> list;@NoArgsConstructor    //加上這個注解@AllArgsConstructor@Datapublic static class Item{......}
}

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/89675.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/89675.shtml
英文地址,請注明出處:http://en.pswp.cn/web/89675.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

基于單片機病床呼叫系統/床位呼叫系統

傳送門 &#x1f449;&#x1f449;&#x1f449;&#x1f449;其他作品題目速選一覽表 &#x1f449;&#x1f449;&#x1f449;&#x1f449;其他作品題目功能速覽 概述 該系統是以單片機STM32F103為核心的基于無線網絡的醫院病房呼叫系統&#xff0c;分為從機和主機兩…

[黑馬頭條]-登錄實現思路

需求分析在黑馬頭條項目中&#xff0c;登錄有兩種方式&#xff1a;一種是用戶輸入賬號密碼后登錄&#xff0c;這種方式登陸后的權限很大&#xff0c;可以查看&#xff0c;也可以進行其他操作&#xff1b;另一種方式就是用戶點擊不登錄&#xff0c;以游客的身份進入系統&#xf…

了解.NET Core狀態管理:優化技巧與常見問題解決方案

前言 歡迎關注dotnet研習社&#xff0c;今天我們聊聊“ .NET Core 中的狀態管理”。 在Web應用程序中&#xff0c;管理和維持狀態是一個非常重要的主題&#xff0c;尤其是在無狀態的環境中&#xff0c;如 HTTP 協議和 RESTful API。對于基于 .NET Core 構建的應用程序&#xff…

504網關超時可能是哪些原因導致?

在網絡訪問中&#xff0c;504 網關超時&#xff08;Gateway Timeout&#xff09;如同一個突然亮起的警示燈&#xff0c;打斷用戶的瀏覽或操作流程。這個 HTTP 狀態碼意味著服務器作為網關或代理時&#xff0c;未能在規定時間內收到上游服務器的響應。引發504錯誤的核心因素有哪…

ComfyUI 常見報錯問題解決方案合集(持續更新ing)

前言&#xff1a; 本文匯總了 5 大高頻問題 及其解決方案&#xff0c;涵蓋&#xff1a; HuggingFace 認證修復&#xff08;Token 申請 手動下載指南&#xff09; ComfyUI 版本更新&#xff08;完整命令 依賴管理&#xff09; 自啟動配置&#xff08;Conda 環境 權限修復&…

完美解決Linux服務器tomcat開機自啟動問題

經過多次測試終于徹底解決tomcat開機自啟動的問題了 PID3ps aux | grep /home/server/shichuan/ | grep java | awk {print $2} if [ -n "$PID3" ]; then 這個判斷pid的方式還是可能出現啟動失敗的情況 # tail -n 1 /home/server/shichuan/logs/catalina.out |grep…

kotlin部分常用特性總結

<h3>Kotlin中類和對象初始化</h3><ul> <li>添加open關鍵字代表可以被繼承</li> <li>Any 是所有類的父類,類似Object,包含 equals() hashCode() toString()方法</li> <li>constructor 關鍵字代表構造函數, constructor關鍵字可…

PHP 就業核心技能速查手冊

# PHP 就業核心技能速查手冊 > 高效聚焦市場所需&#xff0c;快速提升競爭力 --- ## 一、語法基礎&#xff08;必會&#xff01;&#xff09; php // 1. 變量與數據類型 $price 19.99; // 浮點型 $isStock true; // 布爾型 // 2. 流程控制 foreach ($…

從混沌到秩序:數據科學的熱力學第二定律破局——線性回歸的熵減模型 × 最小二乘的能量最小化 × 梯度下降的負反饋控制系統,用物理定律重構智能算法的統一場論

目錄 一、機器學習是什么&#xff1f; 1.1 什么是機器學習&#xff1f; 1.2 機器學習的三大類型 二、線性回歸是什么&#xff1f; 2.1 通俗理解 2.2 數學表達 三、最小二乘法&#xff08;Least Squares Method&#xff09; 3.1 什么是損失函數&#xff1f; 3.2 什么是最小…

BI 數據可視化平臺建設(3)—首頁性能提升實踐

作者&#xff1a; vivo 互聯網大數據團隊- Wang Lei 本文是vivo互聯網大數據團隊《BI 數據可視化平臺建設》系列文章第3篇。 隨著越來越多代碼的堆積&#xff0c;平臺的運行加載性能也在逐步下降&#xff0c;在不同程度上極大地影響了用戶體驗&#xff0c;從而導致用戶流失。本…

基于Python的畢業設計選題管理系統設計與實現

基于Python的畢業設計選題管理系統設計與實現摘要本論文詳細闡述了一個基于Python的畢業設計選題管理系統的設計與實現過程。該系統采用了Python的Tkinter庫構建圖形用戶界面&#xff0c;使用SQLite數據庫存儲數據&#xff0c;實現了高校畢業設計選題過程中的教師出題、學生選題…

如何在HTML5頁面中嵌入視頻

在HTML5中嵌入視頻主要使用<video>標簽&#xff0c;這是一種簡單且標準的方式。以下是詳細步驟和示例&#xff1a; 基礎實現 <!DOCTYPE html> <html> <head><title>視頻嵌入示例</title> </head> <body><!-- 基礎視頻播放器…

java操作Excel兩種方式EasyExcel 和POI

一、POI1.引入依賴<!-- 03 xls--> <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.9</version> </dependency><!-- 07 xlsx --> <dependency><groupId>org.a…

Openlayers 面試題及答案180道(141-160)

《前后端面試題》專欄集合了前后端各個知識模塊的面試題,包括html,javascript,css,vue,react,java,Openlayers,leaflet,cesium,mapboxGL,threejs,nodejs,mangoDB,MySQL,Linux… 。 前后端面試題-專欄總目錄 文章目錄 一、本文面試題目錄 141. 如何在生產環境中優…

LangChain面試內容整理-知識點24:實戰案例:智能助手 Agent 構建

本案例講述如何用LangChain構建一個結合多個工具的智能助手 Agent。智能助手需要理解用戶復雜請求,通過調用不同工具(如搜索、計算、查數據庫等)執行多步推理,再給出答案。LangChain的Agent框架非常適合這種場景。 構建步驟: 確定需求和選擇Agent類型:假設我們要一個能上…

【MATLAB例程】Taylor算法用于TOA(到達時間)的三維標簽位置解算,可自適應基站數量。附下載鏈接

本文給出自適應錨點&#xff08;基站&#xff09;的Taylor算法解算TOA&#xff08;到達時間&#xff09;的MATLAB代碼。參考論文&#xff1a;《基于Taylor-Chan算法的改進UWB室內三維定位方法》中的Taylor算法來解算TOA的復現程序&#xff08;MATLAB&#xff09;。 文章目錄運行…

Eclipse代碼折疊增強插件的安裝與使用

本文還有配套的精品資源&#xff0c;點擊獲取 簡介&#xff1a;Eclipse作為Java開發者的IDE&#xff0c;提供包括代碼折疊在內的多種功能&#xff0c;便于管理與閱讀代碼。本文介紹的“com.cb.eclipse.folding_1.0.6.jar”插件能夠進一步增強Eclipse的代碼折疊能力。安裝后&…

Python day18

浙大疏錦行 python day 18. 內容&#xff1a; 昨天學習了聚類算法的一些基本內容&#xff0c;今天繼續學習相關知識分析簇的特征和相關含義&#xff08;使用可視化來進行分析&#xff0c;也可以使用ai&#xff09; 代碼&#xff1a; shap.initjs() # 初始化 SHAP 解釋器 ex…

WPS文檔中心及文檔中臺遠程命令執行漏洞

【嚴重】WPS文檔中心及文檔中臺遠程命令執行漏洞 漏洞描述 WPS文檔中心是面向個人和企業的云端文檔存儲與管理平臺&#xff0c;WPS文檔中臺是為企業提供的集成化文檔協同與流程管理解決方案&#xff0c;強調API對接與業務系統整合。 在2024年5月之前通過docker私有化部署的版…

WPF 加載和顯示 GIF 圖片的完整指南

WPF 加載和顯示 GIF 圖片的完整指南 在 WPF 中加載和顯示 GIF 圖片需要一些特殊處理&#xff0c;因為 WPF 的 Image 控件默認不支持動畫 GIF。 解決方案一&#xff1a;使用 WpfAnimatedGif 庫&#xff08;推薦&#xff09; 這是最簡單且功能最完整的方法。 實現步驟&#xff1a…