eclipse报错There is no getter for property named 'customer' in 'class cn.huanhuanjun.estore.bean.Customer'
org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'customer' in 'class cn.huanhuanjun.estore.bean.Customer' ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'customer' in 'class cn.huanhuanjun.estore.bean.Customer' org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:172) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:55) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) com.sun.proxy.$Proxy8.updateCustomer(Unknown Source) cn.huanhuanjun.estore.service.ICustomerServiceImpl.updateCustomer(ICustomerServiceImpl.java:39) cn.huanhuanjun.estore.web.servlet.UpdateCustomerInfoServlet.doGet(UpdateCustomerInfoServlet.java:44) cn.huanhuanjun.estore.web.servlet.UpdateCustomerInfoServlet.doPost(UpdateCustomerInfoServlet.java:54) javax.servlet.http.HttpServlet.service(HttpServlet.java:647) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
查了一下
网友博客http://blog.csdn.net/xu_xuan/article/details/43562167上解释的原因是DAO方法中定义的参数与实体中定义的属性不一致导致的。
解决方案:
dao层加@Param("userId")注解即可
public List<DictItem> selectKeyByUserId(@Param("xxx") long xxx);
我检查了一下我自己的代码,发现我的错误是SQL语句中将#{xxx}写成了${xxx},希望以后不要再犯这种错误了