【发布时间】:2016-04-25 07:56:15
【问题描述】:
我的 spring java 模块中有两个上下文
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"SpringBeans.xml");
和
ClassPathXmlApplicationContext helloContext = new ClassPathXmlApplicationContext("HelloBeans.xml");
有两个不同的 xml 文件。现在我必须从context 获取HelloBeans.xml 的bean,从helloContext 获取SpringBeans.xml 的bean,而不刷新上下文。
【问题讨论】:
-
设置 parent 将只允许一种方式访问,您不能通过 parent 访问 child 的 beans