java.lang.NoSuchMethodException: com.example.springboot.mapper.EmployeeMapper.<init>()

Error message

java.lang.NoSuchMethodException: com.example.springboot.mapper.EmployeeMapper.()
No such method exception: it points to an .EmployeeMapper

wrong reason

<select id="getEmpById" resultType="com.example.springboot.mapper.EmployeeMapper">
        select * from employee where id=#{
    
    id}
    </select>

In the sql mapping file, when we use a query, we need to return the type of the query.
I am querying Emplyee, and the resultType property should return the class path of an Employee.
But I returned the classpath of EmployeeMapper

solve

Change the value of resultType to the class path of Employee

    <!--    查询-->
    <select id="getEmpById" resultType="com.example.springboot.domian.Employee">
        select * from employee where id=#{
    
    id}
    </select>

Guess you like

Origin blog.csdn.net/zhang19903848257/article/details/108620066