新建springboot工程,截图如下:
建工程时选择JPA模块
Database中配置mysql连接
填写mysql连接信息
打开view视图
打开persistence
生成的实体类如下
package com.example;
import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;
@Entity
@Table(name = "t_user", schema = "sampledb", catalog = "")
public class TUserEntity {
private int userId;
private String userName;
private Integer credits;
private String password;
private Timestamp lastVisit;
private String lastIp;
@Id
@Column(name = "user_id")
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Basic
@Column(name = "user_name")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Basic
@Column(name = "credits")
public Integer getCredits() {
return credits;
}
public void setCredits(Integer credits) {
this.credits = credits;
}
@Basic
@Column(name = "password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Basic
@Column(name = "last_visit")
public Timestamp getLastVisit() {
return lastVisit;
}
public void setLastVisit(Timestamp lastVisit) {
this.lastVisit = lastVisit;
}
@Basic
@Column(name = "last_ip")
public String getLastIp() {
return lastIp;
}
public void setLastIp(String lastIp) {
this.lastIp = lastIp;
}
}
2022-03-16