class AbstractBeanFactory
public void setParentBeanFactory(BeanFactory parentBeanFactory) {
if (this.parentBeanFactory != null && this.parentBeanFactory != parentBeanFactory) {
throw new IllegalStateException("Already associated with parent BeanFactory: " + this.parentBeanFactory);
}
this.parentBeanFactory = parentBeanFactory;
}
나의 요구 사항은 다른 하나를 AppContext로 참조하는 AppContext 체인을 부모로 참조하는 것입니다. parentage도 AppContext의 해당 DefaultListableBeanFactory
까지 확장됩니다. 즉, Context의 DefaultListableBeanFactory
은 부모 Context의 DefaultListableBeanFactory
을 부모로 참조합니다. 체인의 모든 컨텍스트에있는 Bean을 맨 아래의 AppContext에서 검색 할 수 있도록이 작업이 수행됩니다.Java : spring : AbstractBeanFactory가 부모 BeanFactory를 변경할 수없는 이유는 무엇입니까?
이 체인은 동적이며, 새로운 AppContext가 맨 위에 추가되며 모든 AppContext는 중간에서 삭제 될 수 있습니다.
하지만 중간에서 AppContext를 삭제하고 DefaultListableBeanFactory
부모 관계를 변경하려고하면 위의 예외가 발생합니다.
런타임시 공장 관계를 어떻게 바꿀 수 있습니까?
감사, 감사 비멀
다른 질문에서 문제를 설명했습니다. http://stackoverflow.com/questions/9885350/java-spring-how-to-transfer-beans-from-one-classpathxmlapplicationcontext-to-a – weima