Spring: object not being autowired, works fine in another class
I'm creating an util class, but the problem is that a service class is not being autowired. The autowired class is also used elsewhere, so I just copied the autowire code. And the package is being scanned.
public class X implements Y{
@Autowired
private Z z;
public String getA(B b) {
int a= Integer.parseInt(b);
return z.getD(a);
}
}
Does anyone 开发者_Python百科have any idea why despite this z is still null?
Forgot @Component
The Class X should be declared in the context.
精彩评论