今天在使用mybatis时,出现了一个问题:There is no getter for property named 'user' in 'class com.jyr.wh.domain.User,现记录下来

使用注解的形式写sql语名,参数为一个对象

以下为正确写法:

@Insert(
"INSERT INTO t_user(openId,nickName,gender,language,city,province,country," +
"avatarUrl,unionId,appid,timestamp) " +
"VALUES(#{openId},#{nickName},#{gender},#{language},#{city},#{province},#{country}," +
"#{avatarUrl},#{unionId},#{watermark.appid},#{watermark.timestamp})"
)
int insert(User user);
import java.io.Serializable;

public class User implements Serializable {

    private String openId;
private String nickName;
private String gender;
private String language;
private String city;
private String province;
private String country;
private String avatarUrl;//头像
private String unionId;
private WaterMark watermark; public class WaterMark{
private String appid;
private String timestamp;
}
}
} 以上省略get、set方法

报错找不到user那是因为我的sql写错了,在values的参数中加了形参

@Insert(
"INSERT INTO t_user(openId,nickName,gender,language,city,province,country," +
"avatarUrl,unionId,appid,timestamp) " +
"VALUES(#{user.openId},#{user.nickName},#{user.gender},#{user.language},#{user.city},#{user.province},#{user.country}," +
"#{user.avatarUrl},#{user.unionId},#{user.watermark.appid},#{user.watermark.timestamp})"
)
int insert(User user);

在使用注解方式时形参不用写,只写传的对象的属性即可,加上会报以上错误。

~~~~~~~~~~ 完 ~~~~~~~~~~~~

There is no getter for property named 'user' in 'class com.jyr.wh.domain.User' 异常的更多相关文章

  1. There is no getter for property named 'useName' in 'class cn.itcast.mybatis.pojo.User'

    org.apache.ibatis.exceptions.PersistenceException: ### Error updating database.  Cause: org.apache.i ...

  2. mybatis There is no getter for property named 'xxxx

    mybatis There is no getter for property named 'xxxx 360反馈意见截图16230322799670.png http://blog.sina.com ...

  3. MyBatis查询传一个参数时报错:There is no getter for property named 'sleevetype' in 'class java.lang.Integer

    用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class jav ...

  4. There is no getter for property named 'purchaseApplyId' in 'class java.lang.Long'

    mapper.xml: <delete id="deleteByPurchaseAppyId" parameterType="Long"> < ...

  5. MyBatis3: There is no getter for property named 'code' in 'class java.lang.String'

    mybatis3  : mysql文如下,传入参数为string类型时‘preCode’,运行报错为:There is no getter for property named 'preCode' i ...

  6. mybatis There is no getter for property named 'xx' in 'class java.lang.String

    转载自://http://www.cnblogs.com/anee/p/3324140.html 用mybatis查询时,传入一个字符串传参数,且进行判断时,会报 There is no getter ...

  7. There is no getter for property named 'userSpAndSp' in 'class com.uauth.beans.UserSpAndSp'

    mybatis 报错There is no getter for property named 'userSpAndSp' in 'class com.uauth.beans.UserSpAndSp' ...

  8. There is no getter for property named 'userId' in 'class java.lang.String'

    [ERROR] 2017-01-18 04:37:06:231 cn.dataenergy.common.CenterHandlerExceptionResolver (CenterHandlerEx ...

  9. mybaits错误解决:There is no getter for property named 'parentId ' in class 'java.lang.String'

    在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 比如mapper中如下方法,只有一个String值 publ ...

随机推荐

  1. 按照固定字符数切割字符串 基于python的re正则表达式

    def cut_text(text,lenth): textArr = re.findall('.{'+str(lenth)+'}', text) textArr.append(text[(len(t ...

  2. Curl实现ElasticSearch的增删改查

    一.添加数据(laravel必须安装Curl扩展) $data = [ 'username'=>"张三", 'sex'=>"女", 'age'=&g ...

  3. centos7版本中ssh相关的设置

    1.设置SSH连接端口1.1.关闭SELinux--关闭系统当前selinux# setenforce 0 --关闭系统永久selinux# sed -i 's/SELINUX=enforcing/S ...

  4. Rhel6.6---执行命令df -h卡住不动

    问题描述 nfs服务宕掉后,df -h卡住不动,使用xftp也无法打开文档路径 -bash-4.1# mount /dev/mapper/vg_root-LogVol00 on / type ext4 ...

  5. Linux系统下apt-get命令无法安装常见软件包?

  6. 构建web应用之——maven创建以及SpringMVC配置

    构建web应用第一步需要创建以及配置maven项目管理,同时配置启动SpringMVC,这里推荐参考CSDN的一篇文章链接:https://blog.csdn.net/weixin_42222334/ ...

  7. Spring———bean的创建方式,注入方式,复杂类型注入 概括

    Spring相关概念和类    1.IOC             inverse of control    控制反转   反转了创建对象的方式            以前:new 对象,管理和维护 ...

  8. python学习------模块

    模块(modue)的概念 在计算机程序开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件 ...

  9. ImportError libcublas.so.9.0

    What to do when you've installed cuda and tensorflow, but you get this error right after you import ...

  10. js(含有for if函数)

    1.在定义变量时,尽可能让变量的访问范围最小化 2.弹出单选性别,嵌套for和if函数 <script type="application/javascript">   ...