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

14 浏览
0 Comments

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

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

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

但是如何设置hibernate.format_sql=true呢?这在spring boot中不支持吗?

0
0 Comments

问题的原因是想要在spring-boot中设置hibernate.format_sql属性,但无法达到预期的效果。

解决方法是在application.yml文件中添加以下内容:

jpa:

hibernate:

ddl-auto: update

show-sql: true

properties:

hibernate.format_sql: true

0
0 Comments

在Spring Boot中,可以使用spring.jpa.properties.*来设置任何可用的hibernate属性。因此,spring.jpa.properties.hibernate.format_sql=true也是有效的。可以查看文档的这一部分来了解更多信息。

0