nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named in 'class java.lang.String'
Mapper.xml是这样的
1<select id="findPlanByPersonId" resultMap="BaseResultMap" parameterType="java.lang.String"> 2 select * from t_plan 3 <where> 4 <if test="personId != null">personId = #{personId}</if> 5 </where> 6 </select>
Mapper类中的方法是
Plan findPlanByPersonId(String personId);
就会报上述Exception
解决办法
1.改方法
Plan findPlanByPersonId(@Param(value="personId")String personId);
或者2改xml
1<select id="findPlanByPersonId1" resultMap="BaseResultMap" parameterType="java.lang.String"> 2 select * from t_plan 3 <where> 4 <if test="_parameter != null">personId = #{_parameter}</if> 5 </where> 6 </select>
还有一种方式
只改xml(去掉条件)和Mybatis Generator生成的一样
1<select id="findPlanByPersonId" resultMap="BaseResultMap" parameterType="java.lang.String"> 2 select * from t_plan 3 where person_id = #{personId,jdbcType=varchar} 4 </select>
#{personId,jdbcType=varchar}是重点