spring学习

Injection-Type //setting注入 (重要) 接口注入(不重要) 构造函数注入 --根据索引传参

//bean 的id&name   name可以用特殊字符

//简单属性注入 <property name="....",value="....">

//scope singleton为单列模式  prototype每次拿新对象 //集合装配  

//自动装配autowire    byName(默认的名字是XXXDAO) 和 byType 用得比较多

//生命周期  lazy-init 对整个beans初始化  (用得比较少) init-method init-destory(原理和servlet相似)一般不要和prototype连用

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    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">
   <bean name="userDAO" class="com.yanxi.spring.impl.userImpl">
  <property name="daoid" value="2"></property>
  </bean> 
    <bean name="userDAO1" class="com.yanxi.spring.impl.userImpl">
       <property name="daoid" value="1"></property>
    </bean>
  <bean id="userService" class="com.yanxi.spring.service.UserService" init-method="init" destroy-method="destory"  scope="prototype" autowire="byType">
       <!-- <property name="userDAO" ref="u" />  -->//setting注入
       <!--  <constructor-arg>//构造函数注入
     <ref bean="u"/>
     </constructor-arg>         -->
  </bean>
  <!-- <bean id="userDao" class="com.yanxi.spring.impl.userImpl">
     <property name="sets">
         <set>
              <value>1</value>
              <value>2</value>
              <value>3</value>
         </set>
     </property>
     <property name="lists">
          <list>
               <value>4</value>
               <value>5</value>
               <value>6</value>
               <value>7</value>
          </list>
     </property>
     <property name="maps">
        <map>
           <entry key="1" value="8"></entry>
            <entry key="2" value="8"></entry>
             <entry key="3" value="8"></entry>
              <entry key="4" value="8"></entry>
               <entry key="5" value="8"></entry>
        </map>
     </property>
  </bean> -->
</beans>

转载于:https://my.oschina.net/lcyanxi/blog/719636

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值