欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

There is no getter for property named 'xxx' in 'class java.lang.xxxx'解决办法

程序员文章站 2022-07-15 13:46:00
...

使用mybatis访问数据库报错

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxxxx' in 'class java.lang.Integer'
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
	at com.sun.proxy.$Proxy8.selectOne(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
	at com.sun.proxy.$Proxy10.getBkPeople(Unknown Source)
	......
	at com.google.code.or.binlog.impl.AbstractBinlogParser$Context.onEvents(AbstractBinlogParser.java:339)
	at com.google.code.or.binlog.impl.parser.DeleteRowsEventV2Parser.parse(DeleteRowsEventV2Parser.java:65)
	at com.google.code.or.binlog.impl.ReplicationBasedBinlogParser.doParse(ReplicationBasedBinlogParser.java:129)
	at com.google.code.or.binlog.impl.AbstractBinlogParser$Task.run(AbstractBinlogParser.java:265)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxxxx' in 'class java.lang.Integer'
	at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:380)
	at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:170)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:152)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:48)
	at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116)
	at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:97)
	at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:116)
	at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
	at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
	at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
	at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
	at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
	at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:310)
	at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:45)
	at org.apache.ibatis.scripting.xmltags.TextSqlNode$BindingTokenParser.handleToken(TextSqlNode.java:64)
	at org.apache.ibatis.parsing.GenericTokenParser.parse(GenericTokenParser.java:53)
	at org.apache.ibatis.scripting.xmltags.TextSqlNode.apply(TextSqlNode.java:41)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
	at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
	at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
	... 14 common frames omitted

解决方法一:将接口的参数放入Map中,从Map中取参数。

解决方法二:在接口定义的的参数前加@Param("xxx")注解,xxx即为mapper.xml里对应sql中的参数名。