zoukankan      html  css  js  c++  java
  • Interview

    1-IOC子类,并不同时IOC父类

    父类FatherEnricher,子类SonEnricher。注意:

    • 两者都是lazy-init="true"。除非显示调用Spring getBean(),否则不会IOC
    • 代码中明确只显示调用了(IOC了)子类SonEnricher
    • 而子类SonEnricher的构造函数中,调用了super(“...”,“...”,“...”)

    结果:

    • 父类的两个红色的property并没有IOC注入

    spring.xml

        <bean id="FatherEnricher" class="com.FatherEnricher"
            lazy-init="true">
            <constructor-arg index="0" value="xxx"/>
            <constructor-arg index="1" value="xxx"/>
            <constructor-arg index="2" ref="xxx"/>
            <!--Attention here!!!-->
            <property name="param1" ref="param1_ref"/>
            <property name="param2" value="${param2_value}"/>
        </bean>
    
        <bean id="SonEnricher" class="com.SonEnricher"
            lazy-init="true">
            <constructor-arg index="0" value="xxx"/>
            <constructor-arg index="1" value="xxx"/>
            <constructor-arg index="2" ref="xxx"/>
        </bean>
    

      

    code

    public class SonEnricher extends FatherEnricher{
    	public SonEnricher(xxx,xxx,xxx){
    		super(xxx,xxx,xxx)
    	}
    }
    

      

  • 相关阅读:
    CSS的三种定位方式介绍(转载)
    CSS背景颜色透明
    去除网页滚动条的方法
    es6
    Android复习
    caculater
    字符流
    字节流
    File类
    泛型继承
  • 原文地址:https://www.cnblogs.com/frankcui/p/13477356.html
Copyright © 2011-2022 走看看