java.home=${JAVA_HOME}
environment.name=${OS}
baeldung.presentation=${HELLO_BAELDUNG}. Java is installed in the folder: ${JAVA_HOME}
이렇게 사용하면 된다.
@Value("${baeldung.presentation}")
private String baeldungPresentation;
@Autowired
private Environment environment;
environment.getProperty("baeldung.presentation")
@Component
@ConfigurationProperties(prefix = "baeldung")
public class BaeldungProperties {
private String presentation;
public String getPresentation() {
return presentation;
}
public void setPresentation(String presentation) {
this.presentation = presentation;
}
}
@Autowired
private BaeldungProperties baeldungProperties;
baeldungProperties.getPresentation()
프로퍼티를 얻을 수 있다.