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

错误信息

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;
    }

    @Override
    public 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;
    }

    @Override
    public 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_nation
        where 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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值