mybatis-plus&springboot
** 问题1:mybatis 读取不到 mapper映射文件。
如下:
** 如果引用 mybatis-plus 包
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.1.0</version>
</dependency>
则需要配置
mybatis.mapper-locations=classpath:mapper/*.xml
** 引用 mybatis-plus-boot-starter 包
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
则需要配置
mybatis-plus.mapper-locations=classpath:**/*Mapper.xml
另外如果mapper.xml中的表字段中有BLob等类型的字段,需要指明
typeHandler="org.apache.ibatis.type.BlobTypeHandler",否则加载时会出问题
其他的一些配置:
#mybatis
mybatis-plus:
mapper-locations: classpath:**/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.taikang.obs.model/entity
global-config:
# 数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID",ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: auto
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy: not_empty
#驼峰下划线转换
column-underline: true
#数据库大写下划线转换
#capital-mode: true
#逻辑删除配置
logic-delete-value: 0
logic-not-delete-value: 1
#刷新mapper 调试神器
refresh: true
# 原生配置
configuration:
map-underscore-to-camel-case: true
# 如果需要分页的话,需要将该值修改为false,否则的话会出现一定的问题
cache-enabled: false
mybatis-plus主键生成策略(支持四种策略,3.2.*默认为主键生成策略为雪花算法),但是默认主键生成策略生成的id为64为长度,改长度的主键在web页面中会有问题(js中对于number类型的长度,只能支持53位),所以如果需要修改,可以重写主键生成策略(集成IkeyGenerator或者实现IdGenerator,后边这个需要的mp版本高)。
算法参考:https://www.cnblogs.com/nxzblogs/p/11848681.html
mybatis-plus&springboot的更多相关文章
- springboot成神之——mybatis在spring-boot中使用的几种方式
本文介绍mybatis在spring-boot中使用的几种方式 项目结构 依赖 WebConfig DemoApplication 方式一--@Select User DemoApplication ...
- yml的mybatis的sql查看;Mybatis+Springboot 控制台查看日志,Mybatis结合springboot打印日志
1.配置如图 文件为yml mybatis: mapper-locations: classpath:com/springboot/transaction/mapper/*.xml configura ...
- SpringBoot学习笔记(三):SpringBoot集成Mybatis、SpringBoot事务管理、SpringBoot多数据源
SpringBoot集成Mybatis 第一步我们需要在pom.xml里面引入mybatis相关的jar包 <dependency> <groupId>org.mybatis. ...
- 【mybatis】-- springboot整合mybatis
1.添加依赖 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>m ...
- mybatis整合springboot 以及需要注意的细节
具体怎么整合的网上有很多优秀的博客介绍,这里就直接引用一篇个人觉得非常详细的教程: https://blog.csdn.net/winter_chen001/article/details/77249 ...
- 整合MyBatis(springboot)
pom文件: <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>m ...
- mybatis+druid+springboot 注解方式配置多个数据源
1\数据库配置 #test数据源 spring.datasource.test.url=jdbc:mysql:///db?useUnicode= spring.datasource.test.user ...
- 第五章 springboot + mybatis(转载)
本编博客转发自:http://www.cnblogs.com/java-zhao/p/5350021.html springboot集成了springJDBC与JPA,但是没有集成mybatis,所以 ...
- 第五章 springboot + mybatis
springboot集成了springJDBC与JPA,但是没有集成mybatis,所以想要使用mybatis就要自己去集成.集成方式相当简单. 1.项目结构 2.pom.xml <!-- 与数 ...
- springboot mybatis优雅的添加多数据源
springboot的原则是简化配置,本文试图不通过xml配置,使用configuration配置数据源,并进行简单的数据访问. 并且配置了多数据源,在开发过程中这种场景很容易遇到. 1.依赖 spr ...
随机推荐
- pyqt5-橡皮筋控件QRubberBand
提供一个矩形或线来指示选择或边界 一般结合鼠标事件一同协作 继承于 QWidget import sys from PyQt5.QtWidgets import QApplication, QWidg ...
- POJ 3280 Cheapest Palindrome ( 区间DP && 经典模型 )
题意 : 给出一个由 n 中字母组成的长度为 m 的串,给出 n 种字母添加和删除花费的代价,求让给出的串变成回文串的代价. 分析 : 原始模型 ==> 题意和本题差不多,有添和删但是并无代价 ...
- C# 字符串的长度问题
string str = "aa奥奥"; 如果直接取 str.length,取的就是字符的长度,一个汉字也是一个字符,长度就是4. 一个汉字是两个字节,如果需要统计字节数,可以用下 ...
- 创建maven web项目时,没有web.xml文件
1.问题:创建maven项目时,选择的是创建web-app项目,但是结果配置之后,却没有web.xml文件. 2.解决办法: ------------------------------------- ...
- Xcode磁盘空间清理
http://www.iwangke.me/2013/09/09/clean-xcode-to-free-up-disk-space/#jtss-tsina 这个目录下面的文件也可以隔一段儿时间清理一 ...
- How to call javascript function on page load in asp.net
How to call javascript function on page load in asp.net 解答1,使用RegisterStartupScript来运行 需要注意的是,下面的dem ...
- 有关Dispose,Finalize,GC.SupressFinalize函数-托管与非托管资源释放的模式
//这段代码来自官方示例,删除了其中用处不大的细节using System; using System.ComponentModel; /*** * 这个模式搞的这么复杂,目的是:不管使用者有没有手动 ...
- UEFI手札
基于Intel TianoCore衍生的EDK-II诞生的UEFI,用来取代Legacy BIOS. INF文件 Module Information File,模块描述文件.Module可以是可执行 ...
- EXISTS 和 IN 的查询效率问题
mysql使用总结: 一:EXISTS 和 IN 的查询效率问题 1:当a表的数据小于b表中的数据时 用 IN 的效率是要小于用 EXISTS 的效率 SELECT * FROM a WHERE id ...
- Ubuntu中几个字符小玩意儿
1.黑客帝国特效: 打开终端,输入 sudo apt install cmatrix 即可.安装完成后,在终端输入 cmatrix 即可出现特效. 2.奔跑的小火车: 终端输入:sudo apt in ...