"org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userName' in 'class com.nari.climbing.notice.domain.dto.AddressBookDto'"
时间: 2023-06-28 09:11:25 浏览: 46
这个错误是因为 MyBatis 在映射结果集时无法找到 `AddressBookDto` 类中名为 `userName` 的属性的 getter 方法。你需要检查 `AddressBookDto` 类确保它有一个名为 `getUserName()` 的方法,或者你可以使用 `@Result` 注解来映射结果中的列名到类的属性名,例如:
```java
@Results({
@Result(column = "user_name", property = "userName")
})
public class AddressBookDto {
// ...
}
```
相关问题
org.mybatis.spring.mybatissystemexception: nested exception is org.apache.ibatis.reflection.reflectionexception: there is no getter for property named
这个异常信息是mybatis-spring框架抛出的,意思是在封装查询结果集的时候,无法找到一个名为“propertyName”的属性的getter方法。出现这个异常通常代表着查询结果与映射的实体类属性不匹配,需要检查一下映射文件中的SQL语句和实体类是否正确。
获取失败org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException
在您提供的引用内容中,org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException出现的原因是由于在类com.ducha.zdzr.pojo.entity.YqJjd中没有名为'null'的属性的getter方法。该异常通常是由于MyBatis无法找到指定属性的getter方法而引发的。
另外,您还提到了关于使用parameterType="String"的sql语句中的限制。当您在条件判断中使用类似<when test="username != null">这样的语句时,如果没有在类java.lang.String中找到名为'username'的属性的getter方法,就会出现错误。请确保在sql语句中使用的parameterType参数的类型与代码中传递的参数类型一致。
要解决这个问题,您可以执行以下步骤:
1. 首先,请检查类com.ducha.zdzr.pojo.entity.YqJjd并确保它具有名为'null'的属性的getter方法。
2. 然后,请检查您在条件判断中使用的参数类型,确保它与代码中传递的参数类型一致。
3. 如果您使用的是XML配置文件,请确保在sql语句中指定了正确的参数类型,并且在代码中传递的参数也是与之匹配的。
通过以上步骤,您应该能够解决org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException错误。如果问题仍然存在,请仔细检查您的代码和配置,并确保所有的属性和参数都正确设置和匹配。