属性配置
字段验证策略 FieldStrategy
该策略约定了如何产出注入的SQL,涉及到 insert、update 语句,以及 wrapper 内部的 entity 属性生成的 where 条件。
https://baomidou.com/pages/56bac0/#%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE
config-location:
在mybatis-plus下面配config-location:classpath:mybatis-config.xml,
然后在resource下建一个mybatis-config.xml文件
mapperLocations:与mapper接口对应的xml文件的位置
maven多模块项目的扫描路径以classpath*:mybatis/*.xml方式,加载多个jar包下的XML文件
typeAliasesPackage:类型String,默认值:null ,别名包扫描路径,XML中调用的时候不用包含包名
configuration和config-location不能同时设置,会出现冲突
全局策略配置(码云)
DB策略配置
dbtype
field-strategy
局部策略(优于全局策略)
给全局表名加前缀,加完之后,实体类就不需要显示指定前缀了
给全局表名加前缀,加完之后,实体类就不需要显示指定前缀了
全局和局部的配置,某个字段为null或者为空是否要更新
classpath* 的作用是基于Maven多模块模式,加载多个jar包下的xml文件
classpath* 的作用是基于Maven多模块模式,加载多个jar包下的xml文件
fieldstrategy是重点,默认忽略空,还可以不忽略,以及忽略空和空字符串
mp配置!
table field strategy, not empty
table-prefix
fieldStrategy设置为ignored ,测试方法
fieldStrategy设置为ignored ,测试wrapper中插入实体类
fieldStrategy局部配置
fieldStrategy设置为not-empty的测试
fieldStrategy设置为not-empty,意思为把设置的空串加到数据库中
fieldStrategy设置为添加
fieldStrategy,默认不添加的字段为空的数据
map-underscore-to-camel-case:true
mybatis-config.xml
config-location
config-location 和 configuration 不能同时出现,否则会启动报错
6-3 基本配置
peizhi