Mybatis的映射文件中使用“<”报错

问题描述:

SQL语句查询某个时间段内的数据包含开始时间与结束时间,SQL语句正确但是在Mybatis的映射文件中报错

如下图:

解决办法:

将含有“<”符号的SQL语句放入<![CDATA[ ]]>符号中

 1 <select id="queryTotal" parameterType="com.entity.SelectSumMary" resultType="java.lang.Integer">
 2     select
 3     count(1)
 4     from
 5     summary
 6     <if test="queryCondition.startTime != null">
 7       <![CDATA[where time >= #{queryCondition.startTime}
 8       and time <= #{queryCondition.endTime}
 9       ]]>
10     </if>
11   </select>

参考文档地址:https://blog.csdn.net/qq_41347385/article/details/102720350

posted @ 2020-06-11 09:53  xc888  阅读(523)  评论(0)    收藏  举报