1.导入mybatis和mysql配置
2.数据库连接
server:
port: 8080
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456
url: jdbc:mysql://localhost:3306/springboot?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.example.entity
3.与数据库对应
@Data
@Table(name = "t_user")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "name")
private String name;
@Column(name = "password")
private String password;
@Column(name = "age")
private Integer age;
@Column(name = "phone")
private String phone;
@Column(name = "sex")
private String sex;
}
标签:name,Column,数据库,idea,private,mysql,mybatis,链接 From: https://www.cnblogs.com/zhishizongjie/p/18406567