这个特定类的成员私有字段被注释 @autowired 在服务 JAR 中,当我试图在我的代码中获取类的实例时,@autowired 成员总是返回为空。我在项目的 context.xml 中有以下组件扫描语句,它试图在 JAR 中查找基本包,但似乎空值被注入到带注释的成员中。JAR 内部还有一个 context.xml,它具有与以下相同的组件扫描条目。JAR 源代码现在无法更改,我有什么遗漏吗?
<!-- local WEB-INF/spring-context/spring-application-context.xml -->
<context:annotation-config />
<context:component-scan base-package="blah.blah" />
//this code within my project
//wjc.getMethod() dereferencing comes back null
public class A{
WithinJARInterface wjc = new WithinJARInterfaceImpl()
List someObject = wjc.getMethod()
}
//this code interface within JAR
public interface WithinJARInterface{
public List getMethod() throws Exception();
}
//this code within JAR
public class WithinJARInterfaceImpl implements WithinJARInterface{
//below member always comes back NULL
@Autowired
private JARService jService;
public List getMethod(){.....}
}
public interface JARService{
public List method1();
}
@Service("JARService")
public class JARServiceImpl implments JARService {
public List method1(){ }
}