<!--
此类不能直接实例化,因为此类的构造方法要通过子类调用, 获取子类的相关信息
-->
<bean
id="baseService" class="cn.itcast.shop.service.impl.BaseServiceImpl"
lazy-init="true"> //不能实例化,由子类调用实例化
<property
name="hibernateTemplate" ref="hibernateTemplate" />
</bean>
<bean id="accountService"
class="cn.itcast.shop.service.impl.AccountServiceImpl" parent="baseService"
/>
<bean id="categoryService"
class="cn.itcast.shop.service.impl.CategoryServiceImpl" parent="baseService"
/>
<bean id="baseAction" class="cn.itcast.action.BaseAction"
scope="prototype"> // 多例就是创建时候再实例化,不是启动服务器就创建
<property
name="accountService" ref="accountService" />
<property
name="categoryService" ref="categoryService" />
</bean>
原文:http://www.cnblogs.com/appzhang/p/3756431.html