@Resource annotation is not supported on static fields
问题解决
写set方法,在set方法上做注解
@Component
public final class OAuthUtil {
private static OAuthService oauthService;
@Resource(name = "woldoauthService")
public void setOauthService(OAuthService oauthService) {
OAuthUtil.oauthService = oauthService;
}
}

本文介绍了一种解决@Resource注解不支持静态字段的问题的方法,通过创建set方法并在该方法上使用@Resource注解来实现对静态成员变量的依赖注入。

1511

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



