Could not set property 'xxxx' of 'class 'xxxxxxx' with value 'xxxxxx'

Teacher.mapper.xml

  
  
  
  
   
     
     
     
   
  
 
Student.mapper.xml
  
  
  
  
   
      
  

 错误原因resultMap返回结果类型写错
控制台输出内容

log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'teacher' of 'class com.entity.Teacher' with value 'com.entity.Teacher@2c09505f' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'teacher' in 'class com.entity.Teacher'
### The error may exist in com/entity/Teachermapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select *from teacher where id=?
### Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'teacher' of 'class com.entity.Teacher' with value 'com.entity.Teacher@2c09505f' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'teacher' in 'class com.entity.Teacher'
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
	at com.dao.StudentDao.getStudents(StudentDao.java:17)
	at com.uitl.Test.main(Test.java:16)
Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property 'teacher' of 'class com.entity.Teacher' with value 'com.entity.Teacher@2c09505f' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'teacher' in 'class com.entity.Teacher'
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:175)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:57)
	at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:133)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:368)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:338)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:291)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:266)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:236)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:150)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:60)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
	... 4 more
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'teacher' in 'class com.entity.Teacher'
	at org.apache.ibatis.reflection.Reflector.getSetInvoker(Reflector.java:372)
	at org.apache.ibatis.reflection.MetaClass.getSetInvoker(MetaClass.java:174)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:167)
	... 20 more

 
 

你可能感兴趣的:(Could,not,set,proper,Mybatis)