mybatis------調錯了方法 Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException

測試結果爲:

org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'username' in 'class java.lang.Integer'

### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'username' in 'class java.lang.Integer'


XML爲UserDao.xml


測試類爲:



總結是:測試時,調用錯了mybatis的查詢方法,檢查問題時沒有細緻的檢查代碼,導致在小錯誤上花費了半個小時。

出現這個錯誤是${只能是value} 是字符串拼接不防sql注入,並且大括號裏是value不變;#{這裏面隨便什麼字符都可以} 並且防SQL注入


正確的XML爲:


發佈了103 篇原創文章 · 獲贊 25 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章