Update 67.5. Configure JPA properties.md
parent
b1951f5cf2
commit
a6b73553fd
|
@ -0,0 +1,12 @@
|
|||
### 67.5. 配置JPA属性
|
||||
|
||||
Spring Data JPA已经提供了一些独立的配置选项(比如,针对SQL日志),并且Spring Boot会暴露它们,针对hibernate的外部配置属性也更多些。最常见的选项如下:
|
||||
```java
|
||||
spring.jpa.hibernate.ddl-auto: create-drop
|
||||
spring.jpa.hibernate.naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
|
||||
spring.jpa.database: H2
|
||||
spring.jpa.show-sql: true
|
||||
```
|
||||
(由于宽松的数据绑定策略,连字符或下划线作为属性keys作用应该是等效的)`ddl-auto`配置是个特殊情况,它有不同的默认设置,这取决于你是否使用一个内嵌数据库(create-drop)。当本地EntityManagerFactory被创建时,所有`spring.jpa.properties.*`属性都被作为正常的JPA属性(去掉前缀)传递进去了。
|
||||
|
||||
具体参考[HibernateJpaAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java)和[JpaBaseConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java)。
|
Loading…
Reference in New Issue