今天在使用mybatis中@Mapper注解,编写sql的时候出现 :It was either not specified and/or could not be found for the javaType (java.time.LocalDateTime)
在mybatis3.4以上,加入该依赖即可生效。mapper等跟之前一样无需修改。
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.2</version>
</dependency>
@Update 里面 LocalDate 对应的jdbcType
@Update("UPDATE your_table SET your_date_column = #{date, javaType=java.time.LocalDate, jdbcType=DATE} WHERE id = #{id}")
int updateDate(LocalDate date, int id);
@Update 里面 LocalDateTime对应的jdbcType
@Update("UPDATE your_table SET your_date_column = #{date, javaType=java.time.LocalDateTime, jdbcType=TIMESTAMP} WHERE id = #{id}")
int updateDate(LocalDateTime date, int id);