Spring Autowire不适用于GenericApplicationContext

时间:2012-05-12 14:59:12

标签: spring java-ee dependency-injection autowired

我在尝试构建GenericApplicationContext时遇到了一些问题,所有使用@Autowired注释的字段都为null。以下是构建应用程序上下文的代码:

GenericApplicationContext context = new GenericApplicationContext(
            new DefaultListableBeanFactory());
XmlBeanDefinitionReader lXmlReader = new XmlBeanDefinitionReader(
            context);
lXmlReader.loadBeanDefinitions(new FileSystemResource(      "/applicationContext.xml"));

我确信在applicationContext.xml中正确配置了annotation-config和组件扫描,所以我是否需要更多处理才能显式连接依赖?任何建议都表示赞赏。

0 个答案:

没有答案