日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Exception in thread “main“ org.apache.ibatis.exceptions.PersistenceException奇葩解决方案

發(fā)布時間:2025/3/20 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Exception in thread “main“ org.apache.ibatis.exceptions.PersistenceException奇葩解决方案 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

項目場景:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in com/bjsxt/mapper/UserMapper.xml

問題描述:

在使用mybatis框架,通過id查詢用戶時,出現異常;

</select> <!-- 根據用戶id查詢用戶 參數類型可以不寫--><select id="selectUsersById" parameterType="int" resultType="com.bjsxt.pojo.Users">/* #{}相當于jdbc中的問號,直接在{}中給定綁定參數的名稱;如參數只有一個叫什么都可以,但要是有多個就需要具體參數名稱了;*/select * from users where userid = #{suibian}</select>

原因分析:

這樣的異常:是映射文件出現了錯誤,大多數都是resultType的配置出現了錯誤,但是今天我這個錯誤優(yōu)點奇葩;


解決方案:

將代碼中的注釋刪掉就解決了;

異常代碼

</select> <!-- 根據用戶id查詢用戶 參數類型可以不寫--><select id="selectUsersById" parameterType="int" resultType="com.bjsxt.pojo.Users">/* #{}相當于jdbc中的問號,直接在{}中給定綁定參數的名稱;如參數只有一個叫什么都可以,但要是有多個就需要具體參數名稱了;*/select * from users where userid = #{suibian}</select>

消除異常后代碼:

</select> <!-- 根據用戶id查詢用戶 參數類型可以不寫--><select id="selectUsersById" parameterType="int" resultType="com.bjsxt.pojo.Users">select * from users where userid = #{suibian}</select>

解決后我也是無語了;
在這里再加一句,不論是/* */注釋,還是選中Ctrl+/注釋都是會報相同的異常的;
在這里建議就不要加注釋了,如果真的要加還是放到select標簽外面吧!

總結

以上是生活随笔為你收集整理的Exception in thread “main“ org.apache.ibatis.exceptions.PersistenceException奇葩解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。