57
votes

I'm using spring-boot autoconfiguration for database injection, with properties defined:

spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

But how can I set the hibernate.format_sql=true? Is that not supported by spring boot?

5

5 Answers

129
votes

Spring Boot will let you set any available hibernate property using:

spring.jpa.properties.*

So spring.jpa.properties.hibernate.format_sql=true would work as well.

Check out this part of the documentation

15
votes

If you are using yml format to declare Spring Boot properties, you can use:

spring:
  datasource:
  jpa:
    properties:
      hibernate.format_sql: true
12
votes
jpa:
  hibernate:
    ddl-auto: update
  show-sql: true
  properties:
    hibernate.format_sql: true
7
votes

This is very much available

spring.jpa.hibernate.format_sql=true
6
votes

You can use : spring.jpa.properties.hibernate.format_sql=true

Apart from the documentation, I do follow example from here to configure my application. You can find a sample of properties being used in that.