카테고리 없음

[spring] SpringBootTest 에서 profile 변경하기

냐옴 2023. 9. 20. 13:31

 

@SpringBootTest 의 properties 에 사용할 profile 값을 주입한다

@SpringBootTest(properties = "spring.profiles.active=dev")
//@ActiveProfiles("dev") // 동작안됨
public class ProfileTest {

    @Value("${spring.profiles.active}")
    private String activeProfile;

    @Test
    void test1() {
        System.out.println("activeProfile = " + activeProfile);
    }
}