spring boot集成mybatis只剩两个sql 并提示 Cannot obtain primary key information from the database, generated objects may be incomplete
前言
spring boot集成mybatis时只生成两个sql, 搞了一个早上,终于找到原因了
找了很多办法都没有解决, 最后注意到生成sql的时候打印了一句话:
Cannot obtain primary key information from the database, generated objects may be incomplete
表示生成数据库未完成.
问题描述
在整合mybatis时只是生成了两个insert()函数,并且提示[WARNING] Cannot obtain primary key information from the database, generated objects may be incomplete
解决方法
在jdbc连接url上加nullCatalogMeansCurrent=true
url=jdbc:mysql://localhost:3306/helloword?useUnicode=true&characterEncoding=utf-8&nullCatalogMeansCurrent=true
亲测已经解决
除此之外, 这一点也要注意
mybatis框架提供了非常好用的逆向工程插件,但是在使用过程中会有很多问题。
我在使用中就遇到了只生成insert和insertSeletive方法,而不生成其他根据primary key查询更新删除的方法。
解决方案:
1.检查数据库中的表是否有主键,如果没有主键是不会生成类似selectByPrimaryKey之类的方法的。
2.检查generatorConfig.xml配置文件中的table标签是否把这些属性设为了false,默认是true,如果设为了false则无法生成。
前两点都是网上很容易找到的,第三点是真正的坑点,希望大家不要被坑了。
3.如果使用的mysql驱动是6.x的,那就无法生成,使用5.x版本的就可以生成。
spring boot集成mybatis只剩两个sql 并提示 Cannot obtain primary key information from the database, generated objects may be incomplete的更多相关文章
- 解决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 ...
- Mybatis抛出: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 databas ...
- 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法
spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...
- spring boot集成mybatis(2) - 使用pagehelper实现分页
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- Spring Boot集成MyBatis开发Web项目
1.Maven构建Spring Boot 创建Maven Web工程,引入spring-boot-starter-parent依赖 <project xmlns="http://mav ...
- 详解Spring Boot集成MyBatis的开发流程
MyBatis是支持定制化SQL.存储过程以及高级映射的优秀的持久层框架,避免了几乎所有的JDBC代码和手动设置参数以及获取结果集. spring Boot是能支持快速创建Spring应用的Java框 ...
- spring boot集成mybatis(1)
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- spring boot集成mybatis(3) - mybatis generator 配置
Spring Boot 集成教程 Spring Boot 介绍 Spring Boot 开发环境搭建(Eclipse) Spring Boot Hello World (restful接口)例子 sp ...
- spring boot集成MyBatis 通用Mapper 使用总结
spring boot集成MyBatis 通用Mapper 使用总结 2019年 参考资料: Spring boot集成 MyBatis 通用Mapper SpringBoot框架之通用mapper插 ...
随机推荐
- Vue之创建组件之配置路由!
Vue之创建组件之配置路由!== 第一步: 当然就是在我们的试图文件夹[views]新建一个文件夹比如home 在home文件夹下面新建一个文件index.vue 第二步:在router目录下做如下事 ...
- Linux top命令里面%CPU和cpu(s)的差别
有的同学会把%CPU和us%搞晕,也就是下图所示在top的时候查看cpu的信息. 这时有的同学会问:这两个CPU到底哪个是对的. 其实都是对的,只是表达的意思不一样. 官方解释如下 Cpu(s):34 ...
- Linux进程内存用量分析之堆内存篇
https://mp.weixin.qq.com/s/a6mLMDinYQGUSaOsGYCEaA 独家|Linux进程内存用量分析之堆内存篇 姬晨烜 58技术 2019-12-06 导语 本文将介绍 ...
- Service Mesh 在百度网盘数万后端的落地实践
https://www.infoq.cn/article/vpa6aypkizuqiijzflih
- ftp协议服务器与tinyhttp服务demo
https://www.jianshu.com/p/fb9fcb69efc9 ....... https://www.jianshu.com/p/e9a2e0755496 ============== ...
- Hive 报错
hadoop hive任务失败,原因是GC overhead limit exceeded (OOM) GC Overhead Limit Exceeded error是java.lang.OutOf ...
- linux shell判断文件,目录是否存在或者具有权限
在linux中判断文件,目录是否存在或则具有的权限,根据最近的学习以及网上的资料,进行了以下的总结: #!/bin/sh myPath="/var/log/httpd/" myFi ...
- linux c驴杂记
C语言标准库中包含了各种用于处理错误的函数和宏.1.assert( ) 宏 #include<assert.h>void assert( int expression );可用于诊断程序b ...
- toggle() 隐藏和收缩
<!DOCTYPE html><html><head><script src="/jquery/jquery-1.11.1.min.js" ...
- Web APP和原生 APP的不同
我们现在手机中的APP,大部分都是混合APP,也就是既用到了原生APP的基础,又用到了Web APP的基础,混合的比例从0%到100%之间不等.更好的了解APP的类型,有助于我们学则合适的测试策略.今 ...