解决mybatis generator警告Cannot obtain primary key information from the database, generated objects may be incomplete

 

使用 mybatis generator 生成pojo、dao、mapper时

经常出现 Cannot obtain primary key information from the database, generated objects may be incomplete

无法生成主键相关方法

 

具体详细解决方案有人已经提出了,很长,https://blog.csdn.net/jpf254/article/details/79571396#%E6%9C%80%E7%BB%88%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88

另一个详细解读,http://m.aspku.com/view-326284.html

 

两个解决方案:

1、MySQL数据驱动使用5.X版本

 2、这里记一下简单的解决方法,在数据库连接后面加上 nullCatalogMeansCurrent=true

 

这里贴一下自己的数据库连接的写法,

?serverTimezone=UTC&zeroDateTimeBehavior=round&nullCatalogMeansCurrent=true

本人用的是 mysql-connector-java 8
所以加上第一个 serverTimezone,第二个 zeroDateTimeBehavior 是防止时间为null的解决
posted @ 2018-11-29 11:24  AloeAndClover  阅读(3554)  评论(2编辑  收藏  举报