开发者

Spring: object not being autowired, works fine in another class

开发者 https://www.devze.com 2023-01-25 06:37 出处:网络
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.

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

精彩评论

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