Could not set property 'id' xxx of 'class argument type mismatch
具体错误如下:
2019-06-12 16:43:55.250 ERROR 21428 —- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property ‘id’ of ‘class com.cems.cemspm.gitflow.entity.GitflowBranchEntity’ with value ‘1138728624284139522’ Cause: java.lang.IllegalArgumentException: argument type mismatch] with root cause
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
这个错误遇到了第二次,因为有点时间长了,所以就忘了,耽误了我半个小时左右,解决过一次,实在是说不过去了。
这个是因为,id没法插入,因为虽然数据库中已经设置了 主键并自增,但是 使用注解的实体,还需要另外额外的配置才行:
解决办法:加上黄色的字的部分即可:
/**
* ID序列
*/
@TableId(value = “id”,type= IdType.AUTO)
private Integer id;
原来是这样的:
/**
* ID序列
*/
@TableId
private Integer id;
解决过的问题再花很多时间,实在是没有必要。所以这里记录下,希望能帮助到需要帮助的朋友们。
还没有评论,来说两句吧...