728x90
스프링부트 및 JPA 를 연습할 때, 프로젝트를 생성하면서 항상 구글에 찾아서 작성하지 않으려고, 따로 글을 작성했다.
yml 에 적용할 때는 띄어쓰기가 중요하고 , properties 랑 적용코드가 조금 다르다.
application.yml 설정
// mysql 연결 및 jpa 설정
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
// ? 앞에 shop 은 DB 이름을 작성
url: jdbc:mysql://localhost:3306/shop?serverTimezone=Asia/Seoul
username: root
password: 1234
jpa:
properties:
hibernate:
show_sql: true // DB 에 날리는 모든 쿼리를 보여준다.
format_sql: true // 보여지는 쿼리를 가독성 있게 바꿔준다.
hibernate:
ddl-auto: create
database-platform: org.hibernate.dialect.MySQL8Dialect
// JPA 쿼리에 사용된 파라미터 값을 확인할 수 있다.
logging:
level:
org.hibernate.type: info
참고
https://lannstark.tistory.com/14
Spring Boot SQL 보기 옵션 총 정리
Spring Boot에서 query DSL을 사용하건 spring boot JPA를 사용하건, 쿼리를 튜닝할 때 SQL을 봐야할 때가 있다. 그럴 때 사용할 수 있는 몇 가지 옵션을 조사해 보았다. 환경 : Spring boot 2.* + hibernate 5.3...
lannstark.tistory.com
728x90
'Spring > Spring-detail' 카테고리의 다른 글
JPA Auditing 적용 (0) | 2022.09.13 |
---|---|
JUnit 테스트의 생명주기를 알아보자 (1) | 2022.09.11 |
Spring Security H2 DB 접근하기 (0) | 2022.09.02 |
ResponseEntity<T> (0) | 2022.08.31 |
assertThrows 예외 테스트 (0) | 2022.08.21 |
댓글