Spring的DI依赖注入

xml中依赖注入bean

bean标签下

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <!-- 引入其他配置文件 -->
  <import resource="business/DevicePath_Bean.xml"/>
  <bean id="DevicePathCacheImpl__MCACHE__" class="com.uts.intelligent.pathmanager.cache.DevicePathCacheImpl">
      <!--通过访问到当前类中同名的属性(Set注入,该属性在类中重写了setter方法),通过ref注入bean
      ref标签中的属性: local属性代表当前的xml配置文件中的bean,而bean属性则代表整个容器中改id的bean-->
      <property name="devicePathDAO" >
          <ref local="DevicePathDao"/>
      </property>
  </bean>
  <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="locations">
          <list>
              <value>classpath:memcache.properties</value>
              <value>classpath:jdbc.properties</value>
              <value>classpath:httpclient.properties</value>
              <value>classpath:sign.properties</value>
              <value>classpath:workflow.properties</value>

          </list>
      </property>
  </bean>
</beans>

通过访问到当前类中同名的属性,通过ref注入bean
ref标签中的属性: local属性代表当前的xml配置文件中的bean,而bean属性则代表整个容器中改id的bean

posted @   没有烦恼的猫猫  阅读(18)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示