1. 程式人生 > >mybatis-java8日期格式報錯問題

mybatis-java8日期格式報錯問題

升級jdk8後,實體中日期用LocalDate,時間用LocalDateTime,mybatis在對映時候會報錯如下:

Caused by: java.lang.IllegalStateException: No typehandler found for property showBeginTime     at org.apache.ibatis.mapping.ResultMapping$Builder.validate(ResultMapping.java:151)     at org.apache.ibatis.mapping.ResultMapping$Builder.build(ResultMapping.java:140)     at org.apache.ibatis.builder.MapperBuilderAssistant.buildResultMapping(MapperBuilderAssistant.java:382)     at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildResultMappingFromContext(XMLMapperBuilder.java:378)     at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:280)     at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:252)     at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:244)     at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116)     ... 95 more

解決辦法:

新增依賴:

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-typehandlers-jsr310</artifactId>
    <version>1.0.1</version>
</dependency>