本文介绍了Spring注解@Inject不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有代码@Inject在一个类中可用,但在另一类中不可用. 这是我的代码:
I have the code @Inject works in one class but not in other. Here's my code:
- context.xml
- SellerRetriever.java public class SellerRetriever { @Inject UserDAO userDAO; ... ... }
UserDAO类存在于com.myfashions.dao软件包中. @Inject在Seller.java中不起作用.有什么原因吗?
UserDAO class is present in com.myfashions.dao package. @Inject is not working in Seller.java. Any reason why?
推荐答案我发现了我的错误,我发布了此错误,因为万一有人遇到同样的问题.我使用新的运算符创建了SellerRetriver对象.如果使用新的运算符调用该特定类,则注入将不起作用.
I found my mistake, I'm posting this because in case anyone has the same problem. I used new operator to create an SellerRetriver object. Inject won't work if new operator is used to call that particular class.
更多推荐
Spring注解@Inject不起作用
发布评论