配置连接数据库
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/scott?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=123456
package com.rich.springdatajpa.entity;
import javax.persistence.*;
@Entity
@Table(name="dept")
public class Dept {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="deptno")
private Integer deptno;
@Column(name="dname")
private String dname;
@Column(name="loc")
private String location;
public Integer getDeptno() {
return deptno;
}
public void setDeptno(Integer deptno) {
this.deptno = deptno;
}
public String getDname() {
return dname;
}
public void setDname(String dname) {
this.dname = dname;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}
xfb1989 发布了83 篇原创文章 · 获赞 2 · 访问量 6392 私信 关注