Java注解相关
@TableId注解
需要 import com.baomidou.mybatisplus.annotation.TableId;
xml
<!-- 各个依赖的版本号 -->
<properties>
<spring-boot.version>3.2.5</spring-boot.version>
<java.version>17</java.version>
<mybatis-plus.version>3.5.6</mybatis-plus.version>
<hutool.version>5.8.27</hutool.version>
<netty.version>4.1.109.Final</netty.version>
<dynamic.version>4.2.0</dynamic.version>
<lombok.version>1.18.30</lombok.version>
</properties>
<!-- MyBatis-Plus 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
java
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
@Data
@TableName("table表名")
public class Table实体类 implements Serializable {
//主键ID
@TableId(value = "id",type = IdType.AUTO)
private Long id;
}