💡
原文英文,约200词,阅读约需1分钟。
📝
内容提要
从Spring Boot 3的某个版本开始,使用JPA时,Hibernate增加了数据库连接日志。需要设置两个属性:spring.jpa.hibernate.ddl-auto和spring.jpa.properties.hibernate.connection.url,后者应为${spring.datasource.url}。还可以配置其他连接属性,如自动提交模式和隔离级别。
🎯
关键要点
- 从Spring Boot 3的某个版本开始,Hibernate增加了数据库连接日志。
- 需要设置两个属性:spring.jpa.hibernate.ddl-auto和spring.jpa.properties.hibernate.connection.url。
- spring.jpa.properties.hibernate.connection.url应为${spring.datasource.url}。
- 可以配置其他连接属性,如自动提交模式和隔离级别。
- 自动提交模式的属性为spring.jpa.properties.hibernate.connection.autocommit。
- 隔离级别的属性为spring.jpa.properties.hibernate.connection.isolation,可能的值包括TRANSACTION_READ_UNCOMMITTED、TRANSACTION_READ_COMMITTED、TRANSACTION_REPEATABLE_READ或TRANSACTION_SERIALIZABLE。
- 连接池的最小和最大大小可以通过spring.jpa.properties.hibernate.connection.pool_size进行配置。
➡️