1、 类中需要使用@Component注解
2、 set方法不是 static形容的
3、 举例
@Component
public class TestUtil {
private static String password;
@Value("${test.staticKey.password}")
public void setGeneratorKey(String password) {
TestUtil .password= password;
}
}