关于MySQL主键自增获取到为null值得问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MonkeyBrothers/article/details/80822648

在学习springBoot做项目的时候遇到了数据库表字段明明是自增但是取到的结果却是null的问题。

情况如下:


没有正确取到id,而是为null

解决办法:

在“insert”后中添加如下字段

<insert id="insert" useGeneratedKeys="true" keyProperty="id">
    insert into order_info
</insert>
最后清空浏览器之前的缓存再次重启服务器进行访问即可。

猜你喜欢

转载自blog.csdn.net/MonkeyBrothers/article/details/80822648