@Value annotation can be taken directly in the code to values
As in application.yml
# Custom properties
Leysen:
xCx:
url: aaa
1.java code nonstationary property values, directly on the property plus @Value
@Value("${leysen.xcx.url}") private String xcxUrl;
2.java code attribute values are static, use set methods
private static String xcxUrl; @Value("${leysen.xcx.url}") public void setXcxUrl(String xcxUrl) { XcxUtil.xcxUrl = xcxUrl; }
note:
Notes 1. @ Vaule path is org.springframework.beans.factory.annotation.Value
2. To use the current class @Component such as annotations, is to join spring container