測試結果爲:
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爲: