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