mybatis3.4.0不支持LocalDateTime的解決方法(No typehandler found for property time)
問(wèn)題描述
報(bào)錯(cuò):No typehandler found for property time
(注:time是LocalDateTime類型的字段)
LocalDateTimeTypeHandler
public class LocalDateTimeTypeHandler implements TypeHandler<LocalDateTime> { private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Override public void setParameter(PreparedStatement ps, int i, LocalDateTime parameter, JdbcType jdbcType) throws SQLException { if (parameter != null) { ps.setString(i, formatter.format(parameter)); } else { ps.setTimestamp(i, null); } } @Override public LocalDateTime getResult(ResultSet rs, String columnName) throws SQLException { String dateStr = rs.getString(columnName); return dateStr == null ? null : LocalDateTime.parse(dateStr, formatter); } @Override public LocalDateTime getResult(ResultSet rs, int columnIndex) throws SQLException { String dateStr = rs.getString(columnIndex); return dateStr == null ? null : LocalDateTime.parse(dateStr, formatter); } @Override public LocalDateTime getResult(CallableStatement cs, int columnIndex) throws SQLException { String dateStr = cs.getString(columnIndex); return dateStr == null ? null : LocalDateTime.parse(dateStr, formatter); } }
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> </settings> <typeHandlers> <typeHandler handler="com.vanwardsmart.mybatis.LocalDateTimeTypeHandler" javaType="java.time.LocalDateTime"/> </typeHandlers> </configuration>
到此這篇關(guān)于mybatis3.4.0不支持LocalDateTime的解決方法(No typehandler found for property time)的文章就介紹到這了,更多相關(guān)mybatis3.4.0不支持LocalDateTime內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
定義hashcode時(shí)使用31系數(shù)的原因
這篇文章主要介紹了定義hashcode時(shí)使用31系數(shù)的原因,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01SpringBoot整合Security權(quán)限控制登錄首頁(yè)
這篇文章主要為大家介紹了SpringBoot整合Security權(quán)限控制登錄首頁(yè)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11Spring?Boot實(shí)現(xiàn)文件上傳下載
這篇文章主要為大家詳細(xì)介紹了Spring?Boot實(shí)現(xiàn)文件上傳下載,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-08-08Java利用MD5加鹽實(shí)現(xiàn)對(duì)密碼進(jìn)行加密處理
在開發(fā)的時(shí)候,有一些敏感信息是不能直接通過(guò)明白直接保存到數(shù)據(jù)庫(kù)的。最經(jīng)典的就是密碼了。如果直接把密碼以明文的形式入庫(kù),不僅會(huì)泄露用戶的隱私,對(duì)系統(tǒng)也是極其的不厲。本文就來(lái)和大家介紹一下如何對(duì)密碼進(jìn)行加密處理,感興趣的可以了解一下2023-02-02使用easyexcel導(dǎo)出的excel文件,使用poi讀取時(shí)異常處理方案
這篇文章主要介紹了使用easyexcel導(dǎo)出的excel文件,使用poi讀取時(shí)異常處理方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12