1.导入依赖
<!--JPA-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--Mysql数据库驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
2.Application.properties 配置
#JPA
spring.datasource.url=jdbc:mysql://localhost:3306/dbname?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.tomcat.max-active=100
spring.datasource.tomcat.max-idle=200
spring.datasource.tomcat.initialSize=20
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
3.创建实体类
方式一:手动创建 `繁琐`
给项目添加JPA 使用IDEA的Database+persistence来创建实体类
4创建映射器接口,继承JPARepository 接口