mybatis 报错There is no getter for property named 'XXX' in 'class com.xx.xx'

mybatis报错信息记录:

### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'batchDetails' in 'class com.mybatis.model.Batch'

### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'batchDetails' in 'class com.mybatis.model.Batch'

这个问题会气死人,单词写错了

      <collection property="batchList" ofType="com.mybatis.model.Batch">
            <id column="batch_id" property="batch_id"/>
            <result column="cus_id" property="cus_id"/>
            <result column="number" property="number"/>
            <result column="createtime" property="createtime" javaType="java.util.Date"/>
            <result column="note" property="note"/>
            <!--订单(批次)明细-->
            <collection property="batchDetails" ofType="com.mybatis.model.BatchDetail">
                <id column="id" property="id"/>
                <result column="batch_id" property="batch_id"/>
                <result property="product_id" column="product_id"/>
                <result property="product_num" column="product_num"/>
                <!--每个明细对应单独(一对一)的说明-->
                <association property="finacialProduct" javaType="com.mybatis.model.FinacialProduct">
                    <id column="product_id" property="id"/>
                    <result column="name" property="name"/>
                    <result column="price" property="price"/>
                    <result column="detail" property="detail"/>
                </association>
            </collection>
        </collection>

其中第八行的<collection property="batchDetails",要对应第一行的ofType="com.mybatis.model.Batch">

Bath.java中的字段

public class Batch {
    private int batch_id;
    private int cus_id;
    private String number;
    private Date createtime;
    private String note;
    private List<BatchDetail> batchDetials;
}

这边写的是batchDetials

batchDetials和batchDetails

此类报错和描述的一样,就是找不到,可以全局搜索找一下报错的字段等方法来测试

猜你喜欢

转载自blog.csdn.net/April_Moon/article/details/83414087