반응형
insert
into
member
(username, id)
values
(?, ?)
위의 로그처럼 SpringBoot 개발을 하면서 실행시킨 쿼리의 파라미터가 '?' 로 표시되어 어떤 값인지 확인이 불가능합니다.
다음의 설정을 통해 쿼리 파라미터 값을 확인할 수 있습니다.
yml 파일 속성 추가
# application.yml
logging:
level:
org.hibernate.type: trace
application.yml 파일에 위의 속성을 추가하면 쿼리 아래에 다음과 같이 파라미터 값 로그가 남습니다.
... : binding parameter [1] as [VARCHAR] - [memberA]
... : binding parameter [2] as [BIGINT] - [1]
P6Spy 라이브러리 사용
Git: https://github.com/gavlyukovskiy/spring-boot-data-source-decorator
# build.gradle
implementation "com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.8.0"
build.gradel 파일에 라이브러리를 추가하면 쿼리 아래에 p6spy 로그와 원본 쿼리와 파라미터가 보이는 쿼리 로그가 남습니다.
insert into member (username, id) values (?, ?)
insert into member (username, id) values ('memberA', 1);
P6Ssy에서 제공하는 설정들을 사용하여 다듬을 수 있습니다.
반응형
'웹, 앱 개발 > Spring' 카테고리의 다른 글
@SpringQueryMap란? & 사용 예시 (0) | 2023.03.30 |
---|---|
@SuperBuilder란? & 사용 예시 (1) | 2023.03.28 |
[SpringBoot] sourceCompatibility & targetCompatibility (0) | 2022.07.19 |
[SpringJPA] @Embeddable & @Embedded (Value Type) (0) | 2022.05.23 |
[Spring Boot] Junit5 - @RunWith(SpringRunner.class) (0) | 2022.05.13 |