<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
import org.springframework.data.jpa.repository.JpaRepository;
public interface XxTeacherDao extends JpaRepository<XxTeacher,Integer> {
}
import lombok.Data;
import javax.persistence.*;
@Data
@Entity
@Table(name = "xx_teacher")
public class XxTeacher implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
@Column(name="card_num")
private String cardNum;
@Column(name = "name")
private String name;
private static final long serialVersionUID = 1L;
}
启动springboot代码,注意@SpringBootApplication能扫描到你的代码才可以
@SpringBootApplication
public class Springboot220304Application {
public static void main(String[] args) {
SpringApplication.run(Springboot220304Application.class, args);
}
}