链接 🔗

  • MVNRepository

    安装

    添加依赖:
    1. <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
    2. <dependency>
    3. <groupId>org.springframework.boot</groupId>
    4. <artifactId>spring-boot-starter-data-jpa</artifactId>
    5. <version>2.2.1.RELEASE</version>
    6. </dependency>

配置

  1. ### 必要配置
  2. # MySQL 配置
  3. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  4. spring.datasource.url=jdbc:mysql://localhost:3306/example
  5. spring.datasource.username=root
  6. spring.datasource.password=root
  7. ### 增强配置
  8. # 配置 jpa 如何更新数据库,默认 none
  9. spring.jpa.hibernate.ddl-auto=none
  10. # 配置 jpa mysql 语句打印,默认 false
  11. spring.jpa.show-sql=true
  12. # 配置是否格式化 sql 语句后打印
  13. spring.jpa.properties.hibernate.format_sql=true
  14. # 配置是否打印 sql 语句中的绑定参数
  15. logging.level.org.hibernate.type.descriptor.sql.BasicBinder=trace