1. 程式人生 > >註入抽象類的子類

註入抽象類的子類

test bstr ext abstract 抽象 private config 屬性 ()

public abstract class TestBean {
    private int a =0;
}
public class TestBeanChild extends TestBean {
    int b = 1;

    public void execute() {
        System.out.println("132");
    }
}
    <bean id="testBeanChild" class="com.yundaex.wms.config.TestBeanChild"  />
    @Autowired
    private
TestBean a;

實際註入的是抽象類的子類

TestBeanChild,屬性為a=0,b=1

註入抽象類的子類