如何在spring-boot中设置hibernate.format_sql?

mem*_*und 42 java spring spring-data-jpa spring-boot

我正在使用spring-boot自动配置进行数据库注入,并定义了属性:

spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
Run Code Online (Sandbox Code Playgroud)

但我怎么设置hibernate.format_sql=true?弹簧靴不支持吗?

geo*_*and 97

Spring Boot将允许您使用以下命令设置任何可用的hibernate属性:

spring.jpa.properties.*

所以spring.jpa.properties.hibernate.format_sql=true也会起作用.

查看文档的这一部分


Ank*_*hal 7

这是非常可用的

spring.jpa.hibernate.format_sql=true
Run Code Online (Sandbox Code Playgroud)


Vin*_*uri 5

您可以使用 : spring.jpa.properties.hibernate.format_sql=true

除了文档,我从这里按照示例来配置我的应用程序.您可以找到其中使用的属性样本.


And*_*mov 5

如果您使用yml格式来声明Spring Boot属性,则可以使用:

spring:
  datasource:
  jpa:
    properties:
      hibernate.format_sql: true
Run Code Online (Sandbox Code Playgroud)


小智 5

jpa:
  hibernate:
    ddl-auto: update
  show-sql: true
  properties:
    hibernate.format_sql: true
Run Code Online (Sandbox Code Playgroud)