目录

Java报错Can not find table primary key in Class

报错

项目启动之后,报错 Can not find table primary key in Class: “com.unicloud.common.core.domain.entity.SysDept”.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
09:57:19.227 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.common.core.domain.entity.SysDept".
09:57:19.272 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.common.core.domain.entity.SysDictData".
09:57:19.318 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.common.core.domain.entity.SysDictType".
09:57:19.359 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.system.domain.SysLogininfor".
09:57:19.403 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.common.core.domain.entity.SysMenu".
09:57:19.445 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.system.domain.SysNotice".
09:57:19.489 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.system.domain.SysOperLog".
09:57:19.532 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.system.domain.SysPost".
09:57:19.572 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.system.domain.SysRoleDept".
09:57:19.613 [restartedMain] WARN  c.b.m.c.m.TableInfoHelper - [initTableFields,307] - Can not find table primary key in Class: "com.unicloud.common.core.domain.entity.SysRole".

分析

原因发现没有在实体类的自增主键上加自增主键的注解

./1.png

点击 关/系/外键

./2.png

这个表是有主键的,并且是自增

然而:我们的实体类里

C:\Program_Green\hugo_extended_0.82.0_Windows-64bit\sites\KKKPJSKEY's-Case-Archives\content\posts\Java_Cant_Find_Primary_Key\3.png

解决

我们加上

./4.png

就OK了