1:导入pom.xml依赖(也可在建项目过程中勾选)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
2:application.yml添加配置
spring:
jpa:
hibernate:
ddl-auto: update
show-sql: true
3:jpa自动简表的代码(通过实体类可自动在数据库简表)
@Entity
//数据库表名
@Table(name = "t_springboot_book")
public class Book {
@Id
@GeneratedValue//自动序列化
private Integer bid;
@Column(length = 100)
private String bname;
@Column
private float price;
4:jpa增删改
dao层
package com.zking.springboot05.dao;
import com.zking.