@ConfigurationProperties 사용하기 #1

catch me if u can!·2021년 6월 28일
0
  1. application.properties 아래와 같이 설정되어 있다고 전제한다.
setting1.prop1=value1
setting1.prop2=value2
  1. 설정파일을 빈에서 자동로드하여 사용하기 위해서는 아래와 같은 형식으로 클래스를 정의한다. (Setter를 사용하여 초기화 되므로, Setter를 필수로 정의 하여야 한다)
@Getter
@Setter
@ConfigurationProperties(prefix="setting1")
@Component
public class CustomSetting {
  private String prop1;
  private String prop2;
}
profile
마쿠투소케 난쿠로나이사

0개의 댓글