zoukankan      html  css  js  c++  java
  • mybatis异常:There is no getter for property named 'xxx' in 'xxx'

    在使用mybatis查询的时候出现了下面的异常:

    org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'dictType' in 'class com.up.sell.vo.system.Advertisement'
        at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:419) ~[mybatis-3.4.6.jar:3.4.6]
        at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:164) ~[mybatis-3.4.6.jar:3.4.6]
        at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:162) ~[mybatis-3.4.6.jar:3.4.6]
        at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) ~[mybatis-3.4.6.jar:3.4.6]
        at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) ~[mybatis-3.4.6.jar:3.4.6]

    这个错误的原因是我的resultMap大小写写错了,大家做好看一下实体中的字段和mapper中的大小写,别搞反。

    贴上代码,可以参照一下:

        <resultMap type="Advertisement" id="AdvertisementResult">
            <id property="id" column="id" />
            <result property="title" column="title" />
            <result property="imgPath" column="img_path" />
            <result property="url" column="url" />
            <result property="description" column="description" />
            <result property="sort" column="sort" />
            <result property="place" column="place" />
            <result property="provinceId" column="province_id" />
            <result property="cityId" column="city_id" />
            <result property="advFlag" column="adv_flag" />
            <result property="createUser" column="create_user" />
            <result property="createTime" column="create_time" />
            <result property="updateUser" column="update_user" />
            <result property="updateTime" column="update_time" />
            <association property="areas" column="id" javaType="com.up.sell.vo.system.Areas" resultMap="areasResult" />
            <association property="dictionary" column="id" javaType="com.up.sell.vo.system.Dictionary" resultMap="deptResult" />
        </resultMap>
    
        <resultMap id="areasResult" type="Areas">
            <id property="id" column="id" />
            <result property="areaName" column="area_name" />
            <result property="parentId" column="parent_id" />
            <result property="shortName" column="short_name" />
        </resultMap>
    
        <resultMap id="deptResult" type="Dictionary">
            <id property="dKey" column="d_key" />
            <result property="dValue" column="d_value" />
            <result property="dName" column="d_name" />
            <result property="parentKey" column="parent_ey" />
            <result property="flag" column="flag" />
        </resultMap>
  • 相关阅读:
    个人项目:Java实现WC
    第六篇Scrum冲刺博客
    java实现小学生四则运算
    实现wc部分功能 java
    WordCount作业修改
    我的过去、现在和未来
    WordCount
    Window 通过cmd查看端口占用、相应进程、杀死进程等的命令
    《《《在同一台服务器上配置多个Tomcat
    关于Android 5.x的低功耗蓝牙BLE开发简介
  • 原文地址:https://www.cnblogs.com/itiande/p/9608100.html
Copyright © 2011-2022 走看看