본문 바로가기

날리지

[Spring] static 변수에 injection하지 못 할 때

@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;
	}

}