Home > Back-end >  Mybatis plus3.0 id does not automatically generated
Mybatis plus3.0 id does not automatically generated

Time:10-06

Recently in the use of mybatis plus3.0, tested the id automatically generated strategy, found @ TableId (value="https://bbs.csdn.net/topics/id", type=IdType. ID_WORKER_STR) does not have a id, stick down my configuration code, I am not in springboot use mapper. The XML file
Yml configuration:
# service name and port Settings
Server:
Port: 8080
The servlet:
The context path:/hr

# the DataSource Config
Spring:
Datasource:
Type: com. Alibaba. Druid. Pool. DruidDataSource
The driver - class - name: com. Mysql. Cj). The JDBC driver
Url: JDBC: mysql://localhost: 3306/hr? UseUnicode=true& CharacterEncoding=utf8 & amp; AllowMultiQueries=true& ServerTimezone=GMT
Username: root
Password: 123456
# below to replenish the connection pool Settings, applied to all the data above
# initialization size, minimum, maximum
InitialSize: 5
MinIdle: 5
MaxActive: 20
# configuration access connection wait timeout time
MaxWait: 60000
# configuration interval how to conduct a test, test need to shut down the free connection, the unit is milliseconds
TimeBetweenEvictionRunsMillis: 60000
# to configure a connection in the pool minimum survival time, unit is a millisecond
MinEvictableIdleTimeMillis: 300000
ValidationQuery: SELECT 1 FROM DUAL
TestWhileIdle: true
TestOnBorrow: false
TestOnReturn: false
Open PSCache #, and the size of the specified on each connection PSCache
PoolPreparedStatements: true
MaxPoolPreparedStatementPerConnectionSize: 20
# configuration monitoring statistics of intercepting filters to remove after SQL is unable to statistics, monitoring interface used for firewall
'wall'Filters: stat, wall, logback
LogSlowSql: true
# by connectProperties attribute to open mergeSql function; Slow SQL record
Connection - the properties: druid. Stat. MergeSql=true; Druid. Stat. SlowSqlMillis=5000
# merge multiple DruidDataSource monitoring data
UseGlobalDataSourceStat: true
# web - stat - filter:
# enabled: false
# the JSP, servlet:
# class - name: com. Alibaba. Druid. Support. HTTP. StatViewServlet
# init - parameters:
# loginUsername: druid
# loginPassword: druid
# Logger Config

# mybatis plus
Mybatis - plus:
# mapper - locations: the classpath: XML/mapper/*.
# entity scanning, multiple package with a comma or a semicolon
TypeAliasesPackage: com. ZXL. Hr. Pojo. *
# typeEnumsPackage: com. Baomidou. Springboot. Entity. Enums
Global - config:
# refresh mapper debugging artifact
The db - config:
Key type 0 # : "on the database ID", 1: "the user to enter the ID", 2: "globally unique ID (digital type unique ID)", 3: "globally unique ID UUID";
# id - type: UUID
0 # field strategy: "ignore judgment", 1: "not NULL judgments"), 2: "is not empty judgment
"Field - strategy: not_empty
# hump underline conversion
The column - underline: true
# database capital underlined conversion
# capital - mode: true
# delete logic configuration
Logic - delete - value: 1
Logic - not - delete - value: 0
The db - type: mysql
Refresh: true
# custom filling strategy interface implementation
# meta - object - handler: com. Baomidou. Springboot. XXX
# custom SQL injector
# SQL - injector: com. Baomidou. Mybatisplus. The extension. Injector. LogicSqlInjector
Configuration:
The map - the underscore - to - camel - case: true
Cache - enabled: false
The log - impl: org. Apache. Ibatis. Logging. Stdout. StdOutImpl
Entity class
Package com. ZXL. Hr. Pojo. Sys.

The import com. Baomidou. Mybatisplus. The annotation. *;
The import com. Baomidou. Mybatisplus. The extension. Activerecord. Model;
The import lombok. Data;

Import the Java. IO. Serializable.

/* *
* @ author ZXL
* @ description: user
* @ date 2020/3/16
*/
@ Data
@ TableName (" t_sys_user ")
Public class SysUserTest extends the Model {

/* *
* keys
*/
@ TableId (value="https://bbs.csdn.net/topics/id", type=IdType. ID_WORKER_STR)
private String id;

/* *
* creation time
*/
@ TableField (value="https://bbs.csdn.net/topics/create_date", the fill=FieldFill. INSERT)
Private String createDate;

/* *
* modified time
*/
@ TableField (value="https://bbs.csdn.net/topics/modify_date", the fill=FieldFill. INSERT_UPDATE)
Private String modifyDate;

/* *
* user name
*/
@ TableField (" user_name ")
Private String userName;

/* *
* password
*/
@ TableField (" user_pwd ")
Private String userPwd;

/* *
* encryption password salt
*/
@ TableField (" salt ")
Private String salt;

/* *
* user true name
*/
@ TableField (" real_name ")
Private String realName;

/* *
* gender: 0 male one female
*/
@ TableField (" sex ")
Private String sex;

/* *
* email
*/
@ TableField (" email ")
Private String email;

/* *
* phone
*/
@ TableField (" telephone ")
Private String telephone;

/* *
* mobile phone
*/
@ TableField (" mobile ")
Private String mobile;


/* *
* state
* user state,
* 0: available,
* 1: ban,
*/
@ TableField (" status ")
Private String status;

/* *
* whether leadership: 0 is 1 n
*/
@ TableField (" is_leader ")
Private String isLeader;

/* *
* whether delete (0: not delete 1: deleted)
*/
/* *
After * TableLogic presentation logic to delete, add delete database physical don't delete, will play on this data to delete tags, if hope to physically deleted without the annotations; The tag also shielding the query and update
*/
@ TableField (" does ")
@ TableLogic
Private Integer does;

/* *
* note
*/
@ TableField (" remark ")
Private String remark;

@ Override
Protected the Serializable pkVal () {
Return this. Id;
}

/* *
* the password salt. To define salt again again, the user name + salt, so it is not easy to be cracked, can use a variety of ways to define salt
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related