Spring: object not being autowired, works fine in another class
-
25-09-2019 - |
Question
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 have any idea why despite this z is still null?
Solution
Forgot @Component
OTHER TIPS
The Class X should be declared in the context.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow