开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜