【SpringBoot】Cannot determine value type from string 'xxx' with root cause

開發(fā)SpringBoot過程中程序發(fā)生異常,提示“Cannot determine value type from string 'xxx' with root cause”錯誤,根據(jù)Log顯示數(shù)據(jù)格式錯誤,試了修改數(shù)據(jù)格式,沒用,在此記錄解決辦法。

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'name' from result set.  Cause: java.sql.SQLDataException: Cannot determine value type from string 'xiaoming'
; Cannot determine value type from string 'xiaoming'; nested exception is java.sql.SQLDataException: Cannot determine value type from string 'xiaoming'] with root cause

com.mysql.cj.exceptions.DataConversionException: Cannot determine value type from string 'xiaoming'

解決辦法:這種情況出現(xiàn)還可能是實體類實現(xiàn)有參構(gòu)造函數(shù)后,沒有寫無參構(gòu)造函數(shù),添加無參構(gòu)造函數(shù)即可。

//無參構(gòu)造函數(shù)
public UserBean() {
        
}

public UserBean(String name, int age) {
    this.name = name;
    this.age = age;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容