接口测试报500错误

发布时间 2023-10-11 19:37:26作者: 201812

接口测试的时候报500错误,因为id的信息为空,但是我们又想让数据库自动递增

日志输出 ERROR 7492 --- [nio-8080-exec-1] 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.example.entity.Dept' with value '1712065931527610369' Cause: java.lang.IllegalArgumentException: argument type mismatch] with root cause

原因是我使用的是mybatisplus提供的一些函数,然后id在数据库中设置为自增的,需要在application.properties中添加以下语句

mybatis-plus.global-config.db-config.id-type=auto