으로 나는 follofing 상황 INT "슈퍼 context.xml에"이 :초기화 봄 콩은 후반
가 지금은 여러 다른 프로젝트에서이 "슈퍼의 context.xml"를 사용하고 싶습니다.
public class SubConf ... {
...
@Autowired
ee.Conf superConf;
...
public void setConfloc(Resource res) {
superConf.addSubConf(res);
}
...
}
문제 양자리을 다음과 같이
public class Conf ... {
...
public void addSubConf(Resource res) {
//configuration resolving from res
}
...
}
ee.SubConf가 뭔가 다음과 같이
<import resource="super-context.xml"/>
<bean id="subConf1" class="ee.SubConf">
<property name="confloc" value="classpath:ee/customconf1.sss" />
</bean>
<bean id="subConf2" class="ee.SubConf">
<property name="confloc" value="classpath:ee/customconf2.sss" />
</bean>
...
<bean id="subConfn" class="ee.SubConf">
<property name="confloc" value="classpath:ee/customconfn.sss" />
</bean>
ee.Conf가 뭔가 "하위의 context.xml은"이 말 컨텍스트로드. bean은 다음과 같은 순서로 초기화됩니다 (컨텍스트 파일의 순서에 따라). conf, service, subConf1, subConf2, ... subConfn
그러나 service bean은 실제로 모든 subConf bean에 의존합니다 (이것은 공제 할 수 없지만 문맥 정의 그 자체). subConf bean 정의 다음에 "sub-context.xml"에서 가져 오기가 추가되면 OK를로드합니다.
이유는 모듈성을 구현하고 있기 때문입니다. 가능한 한 늦게 bean을로드하도록 강제 할 수 있습니까 (예제에서는 "service"bean). 가능한 한 빨리 특정 유형의 bean을로드하십시오 (예에서 "subConf"bean). " sub-context.xml "은 부분적으로 원하는 모듈성을 없앱니다.
또는 이러한 유형의 모듈성을 달성하는 가장 순수한 방법은 무엇입니까?
감사합니다. 내 문제가 정확하게 해결되었습니다. 나는 네가 주어진 방식으로 어떤 종류의 모든 콩을 autowire 수 있다는 것을 몰랐다. – Vampnik