@resource注解使用遇到 @Resource annotation is not supported on static fields
Injection of resource dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'javaBeanUtils' defined in file
[E:....out\artifacts\tingyu_Web_exploded\WEB-INF\classes\com\sxt\config\JavaBeanUtils.class]:
Post-processing of merged bean definition failed; nested exception is
java.lang.IllegalStateException: @Resource annotation is not supported on static fi
@resource注入的变量是静态变量,不允许注入静态变量,报错。
解决
1 在被注解类上打上@component
2 将被静态变量上的@resource删除
3 显示打出变量的get/set方法,将两个方法上的 static 删除
4 在set方法上加@resource注解