myBatis中一对一的问题

  • 错误信息
    • 错误代码
    • 问题修改
    • 去掉以后的运行结果,结果正常的输出
    • 注意:如果不去掉上面的那个参数,使用简写的方式也是可以正常的运行

错误信息

Caused by: java.lang.NoSuchMethodException: java.lang.Integer.<init>()at java.lang.Class.getConstructor0(Class.java:3082)at java.lang.Class.getDeclaredConstructor(Class.java:2178)at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:60)... 64 more

错误代码

实体类

package com.itheima.springbootmybatis.domain;import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.SerializableString;
import lombok.Data;import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;public class Employee implements Serializable {private static final long serialVersionUID = 1L;private Integer id;private String name;private String gender;private LocalDate birthday;private String idCard;private String wedlock;private Long nationId;private String nativePlace;private Integer politicId;private String email;private String phone;private String address;private Integer departmentId;private Integer jobLevelId;private Integer posId;private String engageForm;private String tiptopDegree;private String specialty;private String school;private LocalDate beginDate;private String workState;private String workID;private Double contractTerm;private LocalDate conversionTime;private LocalDate notWorkDate;private LocalDate beginContract;private LocalDate endContract;private Integer workAge;private Integer salaryId;private Nation nation;public Employee() {}public Employee(Integer id, String name, String gender, LocalDate birthday, String idCard, String wedlock, Long nationId, String nativePlace, Integer politicId, String email, String phone, String address, Integer departmentId, Integer jobLevelId, Integer posId, String engageForm, String tiptopDegree, String specialty, String school, LocalDate beginDate, String workState, String workID, Double contractTerm, LocalDate conversionTime, LocalDate notWorkDate, LocalDate beginContract, LocalDate endContract, Integer workAge, Integer salaryId, Nation nation) {this.id = id;this.name = name;this.gender = gender;this.birthday = birthday;this.idCard = idCard;this.wedlock = wedlock;this.nationId = nationId;this.nativePlace = nativePlace;this.politicId = politicId;this.email = email;this.phone = phone;this.address = address;this.departmentId = departmentId;this.jobLevelId = jobLevelId;this.posId = posId;this.engageForm = engageForm;this.tiptopDegree = tiptopDegree;this.specialty = specialty;this.school = school;this.beginDate = beginDate;this.workState = workState;this.workID = workID;this.contractTerm = contractTerm;this.conversionTime = conversionTime;this.notWorkDate = notWorkDate;this.beginContract = beginContract;this.endContract = endContract;this.workAge = workAge;this.salaryId = salaryId;this.nation = nation;}public static long getSerialVersionUID() {return serialVersionUID;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getGender() {return gender;}public void setGender(String gender) {this.gender = gender;}public LocalDate getBirthday() {return birthday;}public void setBirthday(LocalDate birthday) {this.birthday = birthday;}public String getIdCard() {return idCard;}public void setIdCard(String idCard) {this.idCard = idCard;}public String getWedlock() {return wedlock;}public void setWedlock(String wedlock) {this.wedlock = wedlock;}public Long getNationId() {return nationId;}public void setNationId(Long nationId) {this.nationId = nationId;}public String getNativePlace() {return nativePlace;}public void setNativePlace(String nativePlace) {this.nativePlace = nativePlace;}public Integer getPoliticId() {return politicId;}public void setPoliticId(Integer politicId) {this.politicId = politicId;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}public String getAddress() {return address;}public void setAddress(String address) {this.address = address;}public Integer getDepartmentId() {return departmentId;}public void setDepartmentId(Integer departmentId) {this.departmentId = departmentId;}public Integer getJobLevelId() {return jobLevelId;}public void setJobLevelId(Integer jobLevelId) {this.jobLevelId = jobLevelId;}public Integer getPosId() {return posId;}public void setPosId(Integer posId) {this.posId = posId;}public String getEngageForm() {return engageForm;}public void setEngageForm(String engageForm) {this.engageForm = engageForm;}public String getTiptopDegree() {return tiptopDegree;}public void setTiptopDegree(String tiptopDegree) {this.tiptopDegree = tiptopDegree;}public String getSpecialty() {return specialty;}public void setSpecialty(String specialty) {this.specialty = specialty;}public String getSchool() {return school;}public void setSchool(String school) {this.school = school;}public LocalDate getBeginDate() {return beginDate;}public void setBeginDate(LocalDate beginDate) {this.beginDate = beginDate;}public String getWorkState() {return workState;}public void setWorkState(String workState) {this.workState = workState;}public String getWorkID() {return workID;}public void setWorkID(String workID) {this.workID = workID;}public Double getContractTerm() {return contractTerm;}public void setContractTerm(Double contractTerm) {this.contractTerm = contractTerm;}public LocalDate getConversionTime() {return conversionTime;}public void setConversionTime(LocalDate conversionTime) {this.conversionTime = conversionTime;}public LocalDate getNotWorkDate() {return notWorkDate;}public void setNotWorkDate(LocalDate notWorkDate) {this.notWorkDate = notWorkDate;}public LocalDate getBeginContract() {return beginContract;}public void setBeginContract(LocalDate beginContract) {this.beginContract = beginContract;}public LocalDate getEndContract() {return endContract;}public void setEndContract(LocalDate endContract) {this.endContract = endContract;}public Integer getWorkAge() {return workAge;}public void setWorkAge(Integer workAge) {this.workAge = workAge;}public Integer getSalaryId() {return salaryId;}public void setSalaryId(Integer salaryId) {this.salaryId = salaryId;}public Nation getNation() {return nation;}public void setNation(Nation nation) {this.nation = nation;}@Overridepublic String toString() {return "Employee{" +"id=" + id +", name='" + name + '\'' +", gender='" + gender + '\'' +", birthday=" + birthday +", idCard='" + idCard + '\'' +", wedlock='" + wedlock + '\'' +", nationId=" + nationId +", nativePlace='" + nativePlace + '\'' +", politicId=" + politicId +", email='" + email + '\'' +", phone='" + phone + '\'' +", address='" + address + '\'' +", departmentId=" + departmentId +", jobLevelId=" + jobLevelId +", posId=" + posId +", engageForm='" + engageForm + '\'' +", tiptopDegree='" + tiptopDegree + '\'' +", specialty='" + specialty + '\'' +", school='" + school + '\'' +", beginDate=" + beginDate +", workState='" + workState + '\'' +", workID='" + workID + '\'' +", contractTerm=" + contractTerm +", conversionTime=" + conversionTime +", notWorkDate=" + notWorkDate +", beginContract=" + beginContract +", endContract=" + endContract +", workAge=" + workAge +", salaryId=" + salaryId +", nation=" + nation +'}';}
}

mapper


package com.itheima.springbootmybatis.mapper;import com.itheima.springbootmybatis.domain.Employee;
import org.apache.ibatis.annotations.Mapper;import java.util.List;@Mapper
public interface EmployeeMapper {/*** 查询全部* @return*/List<Employee> selectAll();
}

xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.springbootmybatis.mapper.EmployeeMapper"><resultMap id="BaseResultMap" type="com.itheima.springbootmybatis.domain.Employee"><id column="id" jdbcType="INTEGER" property="id"/><result column="name" jdbcType="VARCHAR" property="name"/><result column="gender" jdbcType="CHAR" property="gender"/><result column="birthday" jdbcType="DATE" property="birthday"/><result column="idCard" jdbcType="CHAR" property="idCard"/><result column="wedlock" jdbcType="CHAR" property="wedlock"/><result column="nationId" jdbcType="INTEGER" property="nationId"/><result column="nativePlace" jdbcType="VARCHAR" property="nativePlace"/><result column="politicId" jdbcType="INTEGER" property="politicId"/><result column="email" jdbcType="VARCHAR" property="email"/><result column="phone" jdbcType="VARCHAR" property="phone"/><result column="address" jdbcType="VARCHAR" property="address"/><result column="departmentId" jdbcType="INTEGER" property="departmentId"/><result column="jobLevelId" jdbcType="INTEGER" property="jobLevelId"/><result column="posId" jdbcType="INTEGER" property="posId"/><result column="engageForm" jdbcType="VARCHAR" property="engageForm"/><result column="tiptopDegree" jdbcType="CHAR" property="tiptopDegree"/><result column="specialty" jdbcType="VARCHAR" property="specialty"/><result column="school" jdbcType="VARCHAR" property="school"/><result column="beginDate" jdbcType="DATE" property="beginDate"/><result column="workState" jdbcType="CHAR" property="workState"/><result column="workID" jdbcType="CHAR" property="workID"/><result column="contractTerm" jdbcType="DOUBLE" property="contractTerm"/><result column="conversionTime" jdbcType="DATE" property="conversionTime"/><result column="notWorkDate" jdbcType="DATE" property="notWorkDate"/><result column="beginContract" jdbcType="DATE" property="beginContract"/><result column="endContract" jdbcType="DATE" property="endContract"/><result column="workAge" jdbcType="INTEGER" property="workAge"/><result column="salaryId" jdbcType="INTEGER" property="salaryId"/><association property="nation" column="{id=nationId}" select="com.itheima.springbootmybatis.mapper.NationMapper.selectById"/></resultMap><sql id="Base_Column_List">id, name, gender, birthday, idCard, wedlock, nationId, nativePlace, politicId, email,phone, address, departmentId, jobLevelId, posId, engageForm, tiptopDegree, specialty,school, beginDate, workState, workID, contractTerm, conversionTime, notWorkDate,beginContract, endContract, workAge, salaryId</sql><!--查询全部--><select id="selectAll" resultMap="BaseResultMap">select<include refid="Base_Column_List"/>from t_employee</select>
</mapper>


实体类

package com.itheima.springbootmybatis.domain;import lombok.Data;import java.io.Serializable;public class Nation implements Serializable {private Integer id;private String name;public Nation() {}public Nation(Integer id, String name) {this.id = id;this.name = name;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}@Overridepublic String toString() {return "Nation{" +"id=" + id +", name='" + name + '\'' +'}';}
}

mapper

package com.itheima.springbootmybatis.mapper;import com.itheima.springbootmybatis.domain.Nation;
import org.apache.ibatis.annotations.Mapper;@Mapper
public interface NationMapper {Nation selectById(Integer id);
}

xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.springbootmybatis.mapper.NationMapper"><resultMap id="BaseResultMap" type="com.itheima.springbootmybatis.domain.Nation"><id column="id" jdbcType="INTEGER" property="id" /><result column="name" jdbcType="VARCHAR" property="name" /></resultMap><sql id="Base_Column_List">id, name</sql><select id="selectById" parameterType="java.lang.Integer" resultMap="BaseResultMap">select<include refid="Base_Column_List" />from t_nationwhere id = #{id,jdbcType=INTEGER}</select>
</mapper>

问题修改

看着一切都没什么问题,但就是一直报上面的错
错误在哪,请看

去掉以后的运行结果,结果正常的输出

`
``

注意:如果不去掉上面的那个参数,使用简写的方式也是可以正常的运行

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.springbootmybatis.mapper.EmployeeMapper"><resultMap id="BaseResultMap" type="com.itheima.springbootmybatis.domain.Employee"><id column="id" jdbcType="INTEGER" property="id"/><result column="name" jdbcType="VARCHAR" property="name"/><result column="gender" jdbcType="CHAR" property="gender"/><result column="birthday" jdbcType="DATE" property="birthday"/><result column="idCard" jdbcType="CHAR" property="idCard"/><result column="wedlock" jdbcType="CHAR" property="wedlock"/><result column="nationId" jdbcType="INTEGER" property="nationId"/><result column="nativePlace" jdbcType="VARCHAR" property="nativePlace"/><result column="politicId" jdbcType="INTEGER" property="politicId"/><result column="email" jdbcType="VARCHAR" property="email"/><result column="phone" jdbcType="VARCHAR" property="phone"/><result column="address" jdbcType="VARCHAR" property="address"/><result column="departmentId" jdbcType="INTEGER" property="departmentId"/><result column="jobLevelId" jdbcType="INTEGER" property="jobLevelId"/><result column="posId" jdbcType="INTEGER" property="posId"/><result column="engageForm" jdbcType="VARCHAR" property="engageForm"/><result column="tiptopDegree" jdbcType="CHAR" property="tiptopDegree"/><result column="specialty" jdbcType="VARCHAR" property="specialty"/><result column="school" jdbcType="VARCHAR" property="school"/><result column="beginDate" jdbcType="DATE" property="beginDate"/><result column="workState" jdbcType="CHAR" property="workState"/><result column="workID" jdbcType="CHAR" property="workID"/><result column="contractTerm" jdbcType="DOUBLE" property="contractTerm"/><result column="conversionTime" jdbcType="DATE" property="conversionTime"/><result column="notWorkDate" jdbcType="DATE" property="notWorkDate"/><result column="beginContract" jdbcType="DATE" property="beginContract"/><result column="endContract" jdbcType="DATE" property="endContract"/><result column="workAge" jdbcType="INTEGER" property="workAge"/><result column="salaryId" jdbcType="INTEGER" property="salaryId"/><association property="nation" column="nationId" select="com.itheima.springbootmybatis.mapper.NationMapper.selectById"/></resultMap><sql id="Base_Column_List">id, name, gender, birthday, idCard, wedlock, nationId, nativePlace, politicId, email,phone, address, departmentId, jobLevelId, posId, engageForm, tiptopDegree, specialty,school, beginDate, workState, workID, contractTerm, conversionTime, notWorkDate,beginContract, endContract, workAge, salaryId</sql><!--查询全部--><select id="selectAll" resultMap="BaseResultMap">select<include refid="Base_Column_List"/>from t_employee</select>
</mapper>

Caused by: java.lang.NoSuchMethodException: java.lang.Integer.<init>() at java.lang.Class.getConstr相关推荐

  1. 解决:java.lang.NoSuchMethodException: gentle.entity.User.<init>()

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 1. 运行程序报错: java.lang.NoSuchMethodException: gentle ...

  2. ssm报错:SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)

    在更新一个老的服务时,报了如下错误: 环境:jdk1.8,spring3.2 java.lang.IllegalArgumentExceptionat org.springframework.asm. ...

  3. Fel 计算引擎 fel.compile.FelCompiler16.<init>(FelCompiler16.java:40

    **解决办法: ** 将%JAVA_HOME%\lib\tools.jar文件复制到%JAVA_HOME%\jre\lib\目录下 如果不行 将%JAVA_HOME%\lib\tools.jar文件复 ...

  4. Caused by: java.lang.NoSuchMethodException: xx.<init> [class android.content.Context, interface

    详细错误如下: Caused by: java.lang.NoSuchMethodException: com.hly.surfaceview.MySurfaceView.<init> [ ...

  5. java.lang.NoSuchMethodException: com.gql.pojo.User.init() 解决方案

    文章目录 问题说明 解决方案 问题说明 在Spring整合Mybatis时,遇到此问题. Caused by: java.lang.NoSuchMethodException: com.gql.poj ...

  6. 解决报错:java.lang.NoSuchMethodException: com.tangyuan.entity.RicherProduct.<init>()

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 1.报错;java.lang.NoSuchMethodException: com.tangyuan ...

  7. [转载] Controller报错:java.lang.NoSuchMethodException: java.util.List.<init>()

    参考链接: Java8中的java.util.StringJoiner 报错详情: java.lang.NoSuchMethodException: java.util.List.<init&g ...

  8. java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectProvider.<init>()的问题解决

    在使用通用mapper进行crud的时候运行报java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectPr ...

  9. java.lang.NoSuchMethodException: java.util.List.<init>() 问题解决

    java.lang.NoSuchMethodException: java.util.List.() 问题解决 参考文章: (1)java.lang.NoSuchMethodException: ja ...

最新文章

  1. Linux 0.00 代码解析(一)
  2. 如何科学地完成一场 AR 发布会?
  3. 【poi xlsx报错】使用POI创建xlsx无法打开
  4. php cgi路径解析,php.ini中的cgi.fix_pathinfo选项
  5. Flink 读取文本文件,聚合每一行的uid
  6. Eclipse中添加对Python的中文支持
  7. 六、springboot(三)配置双数据源
  8. 【渝粤教育】国家开放大学2018年秋季 2312T旅行社经营管理 参考试题
  9. 点滴积累【JS】---JS小功能(JS实现模仿微博发布效果)
  10. 哈工大2019计算机专业录取分数线,哈尔滨工业大学2019年高考分省分专业录取分数线...
  11. Mike and Chocolate Thieves(CF #361 Div. 2)
  12. UOS安装谷歌浏览器并设置中文
  13. 天涯社区脱水机(TianyaTool) - 实现天涯社区宝箱的只看楼主功能
  14. 简述eureka的自我保护模式? 如何配置其自我保护模式
  15. echarts+echarts-gl vue2制作3D地图+下钻功能+标记点功能,解决dblclick事件失效问题,解决地图下钻后边框不更新保留问题
  16. 多多情报通:拼多多商品推广被限制是什么情况?
  17. 【牛客专项练习】计算机基础—网络基础
  18. 数据挖掘——关联分析基础介绍(上)
  19. 企业运维之 CDN 内容分发网络
  20. 安徽省计算机学校排名,2018“中国最好学科排名”公布 安徽这14所高校上榜

热门文章

  1. python自动调整格式快捷键_pycharm使用技巧之自动调整代码格式总结
  2. 网吧服务器回写盘用什么型号,网吧服务器回写盘的配置
  3. 腾讯收购康盛创想,互联网营销
  4. 高速差分信号线的PCB布线要求
  5. 2020-07-09
  6. 计算机网络-考试题型分析
  7. 【听说有人想转码】入门----求心理阴影面积
  8. Redis学习笔记(八)redis之lua脚本学习
  9. 环信即时通讯的基本集成
  10. Qt/C++编写物联网管理平台41-自动清理早期数据