SPRING

테스트코드에서만 적용되는 yml을 하고 싶을 때

boudle 2024. 7. 1. 17:49

구글링을 했을 때

properties = "classpath:application-test.yml(test .yml)을하면 

test - resource - application-tes.yml을 쓴다고 나오지만 해봐도 결과값은 main에 있는 application.yml을 쓰게된다.

그래서 이를 해결하기 위해서는  ActiveProfiles("test")를 써야한다.

 

properties = "classpath:application-test.yml

 

insert문으로 member가 들어가지만 

아무 변화가 없습니다.

 

@ActiveProfiles("test")

이렇게 실행시키면

 

Member table이 생기는 것을 알 수 있습니다.

'SPRING' 카테고리의 다른 글

[Java] Junit 5  (0) 2024.07.06
[Spring] @NoArgsConstructor vs @AllArgsConstructor  (0) 2024.07.02
[Spring] security DelegatingFilterProxy,FilterChainProxy  (0) 2024.06.26
Spring Boot Batch 사용 결과  (0) 2024.06.23
Spinrg Boot Batch  (0) 2024.06.23