报错:invalid comparison: cn.hutool.core.date.DateTime and java.lang.String的解决方案
错误代码:
<if test="createTime!=null and createTime!='' ">#{createTime},</if>
<if test="updateTime!=null and updateTime!='' ">#{updateTime},</if>
原因分析:
我在pom.xml中导入了
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
深究进入后发现mybatis的版本是3.5.3
<properties>
<mybatis.version>3.5.3</mybatis.version>
<mybatis-spring.version>2.0.3</mybatis-spring.version>
<mybatis-freemarker.version>1.2.0</mybatis-freemarker.version>
<mybatis-velocity.version>2.1.0</mybatis-velocity.version>
<mybatis-thymeleaf.version>1.0.1</mybatis-thymeleaf.version>
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
</properties>
通过面向百度查询,了解到mybatis在3.30版本及以上判定时间时,不能将DateTime类型与字符串进行比较,即不能判空
正确代码
<if test="createTime!=null ">#{createTime},</if>
<if test="updateTime!=null ">#{updateTime},</if>