1、为什么会报语法错误
原因:在 *.xml文件内使用了循环,在mybatis中默认是不允许使用批量修改。
<update id="setMaxMin" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update fm_info
<set>
max_degree= #{item.maxDegree,jdbcType=decimal},
min_degree= #{item.minDegree,jdbcType=decimal},
degree= #{item.degree,jdbcType=decimal}
</set>
<where>
id = #{item.id,jdbcType=INTEGER}
</where>
</foreach>
</update>
2、解决方法
在连接mysql的url后面加上 《 allowMultiQueries=true 》
jdbc.url=jdbc:mysql://localhost:3306/flow_meter?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true