In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about the solution to the failure of SpringBoot integration Mybatis LocalDateTime mapping, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
Failure of SpringBoot integration Mybatis LocalDateTime mapping I. Overview
Recently, in the development of a project, when using SpringBoot to inherit Mybatis, when doing unit tests, due to the need to update the data according to the parameter (type LocaDateTime), it was found that the update record was 0.
At first, I thought the transaction was not committed (autocommit is not enabled by Mybatis by default), but later, it was successful. So exclude uncommitted transactions.
Second, specific reasons
In the entity PO class, you can use Java.sql.Date,Java.sql.Timestamp,java.util.Date to map to the database date,timestamp,datetime. But many of these classes' methods are out of date.
The LocalDate,LocalDateTime,LocalTime of Java8's API is now more commonly used. But,
My version of mybatis (3.5.3) does not support the date and time of Java8. (by default, Mybatis is the time and date on which Java8 is not supported)
III. Solutions
1. Introduce the dependency of type conversion
Org.mybatis mybatis-typehandlers-jsr310 1.0.1
two。 Configure in the Mybatis.config.xml file
Fourth, make a summary
Finding and solving problems is also an improvement in ability. If there are any mistakes in the above, I hope you can correct them.
Error reporting problems using LocalDateTime
When using mybatis for query, the time field is set to LocalDatetime and an error is reported.
Org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'CREATE_TIME' from result set. Cause: java.sql.SQLFeatureNotSupportedException
; null; nested exception is java.sql.SQLFeatureNotSupportedException
Looked at the online solutions are all the same, and finally found an effective way in the comments.
Solution method
Upgrade the druid data source, I can upgrade to version 21. In short, use a higher version of the data source
Com.alibaba druid-spring-boot-starter 1.1.21 after reading the above, do you have any further understanding of the solution to the failure of SpringBoot integration Mybatis LocalDateTime mapping? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.