链接 🔗
- MVNRepository
安装
添加依赖:<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
配置
### 必要配置
# MySQL 配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/example
spring.datasource.username=root
spring.datasource.password=root
### 增强配置
# 配置 jpa 如何更新数据库,默认 none
spring.jpa.hibernate.ddl-auto=none
# 配置 jpa mysql 语句打印,默认 false
spring.jpa.show-sql=true
# 配置是否格式化 sql 语句后打印
spring.jpa.properties.hibernate.format_sql=true
# 配置是否打印 sql 语句中的绑定参数
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace