org.mybatis.spring.MyBatisSystemException : nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘token_exptime’ in ‘class com.zyd.beans.Admin’
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
Caused by: org.apache.ibatis.reflection.ReflectionException : There is no getter for property named ‘usersname’ in ‘class com.zyd.beans.Admin’
…
原因:
实体类的定义里和数据库里列名定义相同为token_exptime,因此自动获取到的变量都是和实体类中定义的相同名字为token_exptime,
但在mapping的xml文件中数据库语句里
token_exptime 写成了tokenExptime,spring找不到token_extime因此就报错.
反观这个错误发生的原因,这个mapping.xml文件是mybatis generater
自动生成的,数据库中定义为token_exptime,所以只能有一个可能那就是自动生成的代码中对参数的定义是没有下划线”_”这种符号的,所以以后在数据库中定义属性名字是不应该带下划线,否则要改很多地方。