今天在寫mapper.xml檔案中我用
誤加了注釋,然後報了這個錯
具體異常如下
Caused by: org.xml.sax.SAXParseException; lineNumber: 134; columnNumber: 10; 元素類型為 "mapper" 的内容必須比對 "(cache-ref|cache|resultMap*|parameterMap*|sql*|insert*|update*|delete*|select*)+"。
錯誤代碼
/** 公共條件 */
<sql id="commonIfWhere">
<if test='params.projectId != null and params.projectId != ""'>
and project_id = #{params.projectId}
</if>
<if test='params.id!= null and params.id != ""'>
and id = #{params.id}
</if>
</sql>
改正之後
<!-- 公共條件 -->
<sql id="commonIfWhere">
<if test='params.projectId != null and params.projectId != ""'>
and project_id = #{params.projectId}
</if>
<if test='params.id!= null and params.id != ""'>
and id = #{params.id}
</if>
</sql>
問題順利解決。
此文章是我開發過程的一個記錄,友善我日後學習和複盤。若能幫到你不勝榮幸。