我有兩個疑問引用豆新的bean實例...讓每一次
1)我有豆Spring容器本身的intialized當Spring容器intialiazed並在撥打電話前查詢到get bean()方法,這是默認行爲,我怎樣才能以這樣的方式配置應用程序,使得只有在調用getbean()時才允許bean在容器中初始化,我們是否應該將bean聲明爲原型爲了達成這個。
2)第二個查詢是第一請到通過下面的例子中第一...
<beans>
<bean id="triangle" class="Demo.Triangle" scope="singleton" >
<property name="pointA" ref="zeropoint"/>
<property name="pointB" ref="firstpoint"/>
<property name="pointC" ref="secondpoint"/>
</bean>
<bean id="zeropoint" class="Demo.Point" scope="prototype" >
<property name="x" value="10" />
<property name="y" value="20" />
</bean>
<bean id="firstpoint" class="Demo.Point" scope="prototype" >
<property name="x" value="10" />
<property name="y" value="20" />
</bean>
<bean id="secondpoint" class="Demo.Point" scope="prototype">
<property name="x" value="10" />
<property name="y" value="20" />
</bean>
正如上面那個三角形豆表明是單以及它引用的bean是protoype現在,當我訪問獨居其他refernces bean的zeropoint,firstpoint和secondpoint也只是針對三角形初始化一次,但是在這裏我希望每當這個三角形bean被提取時創建這三個bean的新實例,請告知這是如何實現的。它是通過我的POJO實現了ApplicationContextAware接口實現的,請大家指教
thanka很多,完美的探索,保持它.. – user1508454 2012-07-11 18:17:17