source

휴지 상태를 설정하는 방법.spring-boot에서 format_sql을 사용할 수 있습니까?

myloves 2023. 3. 29. 22:07

휴지 상태를 설정하는 방법.spring-boot에서 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에서는 다음과 같은 방법으로 사용 가능한 휴지 상태 속성을 설정할 수 있습니다.

spring.jpa.properties.*

그렇게spring.jpa.properties.hibernate.format_sql=true잘 될 것 같아요.

문서의 이 부분을 참조하십시오.

사용하시는 경우yml형식을 지정하여 Spring Boot 속성을 선언할 수 있습니다.

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

이것은 매우 많이 사용할 수 있습니다.

spring.jpa.hibernate.format_sql=true

다음을 사용할 수 있습니다.spring.jpa.properties.hibernate.format_sql=true

문서와는 별도로 어플리케이션을 설정하기 위해 여기서부터의 예를 따릅니다.여기서 사용되는 속성 샘플을 찾을 수 있습니다.

아래 속성 따라하기

spring.jpa.properties.동면하다format_sql=true

    #Turn Statics On
    spring.jpa.properties.hibernate.generate_statistics=true
    logging.level.org.hibernate.stat=debug
    
    #Show all queries
    spring.jpa.show-sql=true
    spring.jpa.properties.hibernate.format_sql=true
    logging.level.org.hibernate.type=trace

언급URL : https://stackoverflow.com/questions/25720396/how-to-set-hibernate-format-sql-in-spring-boot