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)
    	}
    }
    

      

  • 相关阅读:
    12-单表查询
    11-数据的增删改
    10-外键的变种 三种关系
    09-完整性约束
    08-数据类型(2)
    07-数据类型
    06-表的操作
    05-库的操作
    Spring:(六) 代理模式
    Spring:(五) 注解
  • 原文地址:https://www.cnblogs.com/frankcui/p/13477356.html
Copyright © 2011-2022 走看看