**
簡單配置說明
**
最近正在做的項目在用MyBatis-Plus,給自己做一份隨手筆記。
MyBatis-Plus 的配置異常的簡單
SpringBoot工程:
配置MapperScan註解
@SpringBootApplication
@MapperScan("com.example.mybatispluseasydemo")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
常用註解
@TableName:對數據表名註解
@TableId:表主鍵標識
@TableId(value = “id”, type = IdType.AUTO):自增
@TableId(value = “id”, type = IdType.ID_WORKER_STR):分佈式全局唯一ID字符串類型
@TableId(value = “id”, type = IdType.INPUT):自行輸入
@TableId(value = “id”, type = IdType.ID_WORKER):分佈式全局唯一ID 長整型類型
@TableId(value = “id”, type = IdType.UUID):32位UUID字符串
@TableId(value = “id”, type = IdType.NONE):無狀態
@TableField:表字段標識
@TableField(exist = false):表示該屬性不爲數據庫表字段,但又是必須使用的。
@TableField(exist = true):表示該屬性爲數據庫表字段。
@TableField(condition = SqlCondition.LIKE):表示該屬性可以模糊搜索。
@TableField(fill = FieldFill.INSERT):註解填充字段 ,生成器策略部分也可以配置!
@FieldStrategy:
@FieldFill
@Version:樂觀鎖註解、標記
@EnumValue:通枚舉類註解
@TableLogic:表字段邏輯處理註解(邏輯刪除)
@SqlParser:租戶註解