[Spring] spring-vault에서 @VaultPropertySource 여러개 사용하면 안되는 이유
안녕하세요, 하마연구소 입니다. 스프링 기반의 어플리케이션을 개발할 때, 환경설정으로 보안정보를 다루기 위하여 Vault를 이용합니다. 일반적으로 가장 간단하게 Vault를 이용하는 방법은 @VaultPropertySource 또는 @VaultPropertySources 어노테이션을 사용하는 것입니다. 1 2 3 4 5 6 7 8 9 10 11 12 import org.springframework.context.annotation.Configuration ; import org.springframework.vault.annotation.VaultPropertySource ; @Configuration @VaultPropertySource (value = { "secret/hippolab/wallet1" , "secret/hippolab/wallet2" , "secret/hippolab/wallet3" , "secret/hippolab/wallet4" }) public class VaultConfig { } 위 샘플코드에서는 wallet1, wallet2, wallet3, wallet4에 선언된 모든 환경설정은 어플리케이션 로딩시에 스프링 MutablePropertySources에 포함되어 ${vault.properties1}과 같이 쉽게 사용할 수 있습니다. 그러나 어플리케이션을 만들다보면 여러개의 @VaultPropertySource 어노테이션을 서로 다른 파일에 작성해야할 경우가 있습니다. 이럴때는 아래와 같이 VaultConfig1.java와 VaultConfig2.java 파일에 나눠서 코딩하였습니다. 1 2 3 4 5 6 7 8 9 10 11 12 import org.springframework.context.annotation.Configuratio...