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;
}
}
本文介绍了在Java中,如何在TestUtil类中使用@Component注解,并强调了set方法不应用于static修饰符的情况,通过@Value注解动态设置静态变量password的示例。

5577

被折叠的 条评论
为什么被折叠?



