[Spring] 정적 속성에 프로퍼티파일의 값 할당하기 static field init value of properties file
프로그램 자료/Java & Spring 2018. 7. 20. 15:50출처 : https://www.mkyong.com/spring/spring-inject-a-value-into-static-variables/
@Component 를 꼭 써줘야 한다
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class GlobalValue {
public static String DATABASE;
@Value("${mongodb.db}")
public void setDatabase(String db) {
DATABASE = db;
}
}