springboot 项目保存数据时偶然出现的异常 nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'id'



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 。。。
java.lang.IllegalArgumentException: argument type mismatc

解决方法:

实体类上加上了主键自增策略

@TableId(type = IdType.AUTO)

public Integer id;

或者在配置文件中全局配置

mybatis-plus:

  global-config:

    db-config:

      id-type: AUTO


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM