您的位置:首页 > 运维架构

[SSM]There is no getter for property named 'token_exptime' in 'class com.hdu.model.Student'

2016-11-14 11:31 811 查看
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,所以只能有一个可能那就是自动生成的代码中对参数的定义是没有下划线”_”这种符号的,所以以后在数据库中定义属性名字是不应该带下划线,否则要改很多地方。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mybatis
相关文章推荐