解决:nested exception is org.apache.ibatis.reflection.ReflectionException

编程入门 行业动态 更新时间:2024-10-28 05:15:07

解决:nested exception is <a href=https://www.elefans.com/category/jswz/34/1768206.html style=org.apache.ibatis.reflection.ReflectionException"/>

解决:nested exception is org.apache.ibatis.reflection.ReflectionException

错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘id’ in ‘class java.lang.String’

映射器类(Mapper interface)

public interface NarCodeService {public NarCode getNarCode(String id);}

Xml映射文件配置(部分)

<select id="getNarCode" parameterType="java.lang.String"resultType="narCode">select<include refid="Base_Column_List"></include>from nar_code<where><if test="id != null">id=#{id,jdbcType=VARCHAR}</if></where></select>

这是Mybatis Xml映射文件配置,当我执行这个映射select语句时报错:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘id’ in ‘class java.lang.String’

解决办法有两种:

1.去掉sql语句的if标签限制

<if test="id != null">id=#{id,jdbcType=VARCHAR}
</if><-- 改为:-->
id=#{id,jdbcType=VARCHAR}

原因:我自己猜测加上if标签时,id属性没有包含在数据类型为String id对象中。
如果去掉if标签时直接使用这个数据类型为String id对象

2.将parameterType="java.lang.String"参数改为传一个自定义实体对象或者HashMap来封装这个id参数
原因:可以在自定义实体对象或者HashMap中找到这个id属性

转载于:.html

更多推荐

解决:nested exception is org.apache.ibatis.reflection.ReflectionException

本文发布于:2024-03-07 15:55:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1718252.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:org   exception   nested   apache   ReflectionException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!