1.導(dǎo)入依賴
<!--JPA-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--Mysql數(shù)據(jù)庫(kù)驅(qū)動(dòng)-->
<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.創(chuàng)建實(shí)體類
方式一:手動(dòng)創(chuàng)建 `繁瑣`
給項(xiàng)目添加JPA 使用IDEA的Database+persistence來創(chuàng)建實(shí)體類
4創(chuàng)建映射器接口,繼承JPARepository 接口
JpaRepository.png