我們的實體類里面一個字段的日期類型是util.Date,在向數據庫插入該實體時會報錯,說是 日期哪個字段 Data truncation。所以需要做些更改
在mybatis的MAPPER映射文件中對插入的日期進行相應屬性的設置
<insert id="addComment" parameterType="NewsComment">
insert into news_comment(newsid,content,author,createdate) values(#{newsDetail.id},
#{content},#{author},#{createdate,jdbcType=DATE})
</insert>