開發(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;
}