ioc_di (1)

/* 这里一定要注意配置文件是相对于workSpace为根路径来寻找的 */
    BeanFactory factory = new FileSystemXmlApplicationContext("./src/main/resources/hello.xml");

=====

<bean id="greetingService" class="com.springinaction.chapter01.hello.GreetingServiceImpl">
    <!-- String -->
    <property name="greeting" value="Buenos Dias!" />
   
    <!-- int -->
    <property name="testInt" value="22" />
   
    <!-- object -->
    <property name="man">
     <!-- <ref bean="girl"/>  -->
     <ref local="girl"/>
    </property>
   
  </bean>
 
  <!-- 定义对象bean -->
  <bean id="boy" class="com.springinaction.chapter01.hello.Boy"></bean>
  <bean id="girl" class="com.springinaction.chapter01.hello.Girl"></bean>

你可能感兴趣的:(xml,bean,IOC)