How mybatis uses the date localdate and localdatetime in Java 8

preface

I believe everyone should know that Java can be used in entity sql. Date、java. sql. Timestamp、java. util. Date to map to the date, timestamp, datetime and other fields of the database

However, Java sql. Date、java. sql. Timestamp、java. util. Date classes are not easy to use, and many methods are outdated.

There are some new APIs in Java 8. Localdate, Localtime and localdatetime are very easy to use

By default, the time and date of Java 8 are not supported in mybatis. If you use it directly, the following errors will be reported

The solution is as follows:

Directly add the following dependencies

After configuring this dependency, you can replace the date in the entity with localdate and localdatetime, and the others do not need to be changed

The above is only available in mybatis 3.4 The test is valid in version 0

If you are using a version of mybatis lower than 3.4 0, you also need to configure the following

summary

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>