import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; public class MyComponent { @Value("${my.property}") private String myProperty; public String getMyProperty() { return myProperty; } }
#在application.properties檔案中,你可以定義my.property:
my.property=Hello, World!