我想注入在子类的父类中定义的bean。 父母
abstract class ParentService
{
private ParentDao parentDao;
public void foo()
{
parentDao.doStuff();
}
}
<bean id="parentService" class="core.sample.ParentService" abstract="true">
</bean>
class ChildService1 extends ParentService
{
//This calls childDao1.
//what goes here?
}
class ChildService2 extends ParentService
{
//This calls childDao2.
//what goes here?
}
<bean id="childDao1" class="core.sample.ChildDao1">
</bean>
<bean id="ChildDao2" class="core.sample.ChildDao2">
</bean>
ChildDao1 和 ChildDao2 是 ParentDao 的子类。
另外,请提出如何将泛型用于同一用途。