1. 程式人生 > >Spring IoC(1) ---XML方式

Spring IoC(1) ---XML方式

<?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-2.0.xsd">

    <bean id="floppy" class="IoC.FloppyWriter"/>
    <bean id="usb" class="IoC.UsbDiskWriter"/>
    <bean id="businessBean" class="IoC.BusinessBean">
        <property name="deviceWriter">
            <ref bean="floppy"/>
        </property>
    </bean>
</beans>