构造注入和集合

来源:互联网 发布:coc双王升级黑水数据 编辑:程序博客网 时间:2024/06/01 08:58

Ioc和Aop使用扩展

DI注入(设置注入/构造注入/p命名注入)

1.构造注入

第一步(1)

 

 


(类二)

第二步:Xml文件


第三步:单测

 

 

2.集合注入

第一部(集合类)

 


 

<!第二步:proprotice      <beanid="proprtes"class="cn.gouzhao.collection">
        <propertyname="properties">
            <props>
                <propkey="001"></prop>
            </props>
        </property>
    </bean>

 

 

3.(DI)注解 1.(小案例)

第一步:xml

<?xml version="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
>
  <context:component-scanbase-package="cn.zhujiDI"/>
</beans>

第二步:实体类(Student)

 

 

 

Car类

 

第三步

 


 

原创粉丝点击