报错信息:
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 166; columnNumber: 93; The content of elements must consist of well-formed character data or markup.
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:259) ~[mybatis-3.4.0.jar:3.4.0]
原因:
因为语句中有一个小于号“<”,在XML中,会被当成一个页面元素来解析,不会处理为mysql的SQL语句的组成部分
解决:
<if test="timeUnit != null and timeUnit == 5">
<![CDATA[
and timestampdiff(second, create_time, now()) <= 2592000
]]>
</if>
ps:适用于所有的<> <= >=