mybatis-plus依赖导入
com.baomidou
mybatis-plus-boot-starter
3.3.2
建议使用3.3.0后的版本。
导入mybatis-plus就不用导入mybatis了,冲突!
连接数据库
spring.datasource.username=root
spring.datasource.password=19981204
spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl//配置默认日志
设置主键自增
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
private Integer age;
private String email;
}
使用注解 @TableId(type=I