隨筆 - 303  文章 - 883  trackbacks - 0
          <2007年9月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          歡迎光臨! 
          閑聊 QQ:1074961813

          隨筆分類(lèi)(357)

          我管理的群

          公共blog

          • n維空間
          • Email : java3d@126.com 群 : 12999758

          參與管理的論壇

          好友的blog

          我的其他blog

          朋友的網(wǎng)站

          搜索

          •  

          最新評(píng)論

          對(duì)于前個(gè)一代碼這個(gè)代碼加<ref bean=""/>使用和一些調(diào)試的System.out.println()從中你可以看到spring2.0的執(zhí)行過(guò)程

          /src/applicationContext.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="strvalue" class="com.lusm.spring.test.StrValue">
                  
          <property name="str">
                      
          <value>再見(jiàn)了!!!</value>
                  
          </property>       
              
          </bean>

              
          <bean id="hello" class="com.lusm.spring.test.Hello" abstract="false"
                  lazy-init
          ="default" autowire="default" dependency-check="default">
                  
          <property name="str">
                      
          <value>你好啊!!!</value>
                  
          </property>
                  
          <property name="sv">
                      
          <ref bean="strvalue" />
                  
          </property>
              
          </bean>

          </beans>

          /src/com/lusm/spring/test/StrValue.java

          package com.lusm.spring.test;

          public class StrValue {
              
              String str;
              
              StrValue()
          {
                  System.out.println(
          "StrValue class is builded");
              }

              
              
          public void SayGY(){
                  System.out.println(str);
              }


              
          public String getStr() {
                  
          return str;
              }


              
          public void setStr(String str) {
                  
          this.str = str;
              }

          }

          /src/com/lusm/spring/test/Hello.java

          package com.lusm.spring.test;

          public class Hello {
              
          private String str;
              
          private StrValue sv;

              
          public String getStr() {
                  System.out.println(
          "getStr");
                  
          return str;
              }


              
          public void setStr(String str) {
                  System.out.println(
          "setStr");
                  
          this.str = str;
              }


              
          public void sayHello() {
                  System.out.println(str);
              }


              
          public StrValue getSv() {
                  System.out.println(
          "getSv");
                  
          return sv;
              }


              
          public void setSv(StrValue sv) {
                  System.out.println(
          "setSv");
                  
          this.sv = sv;
              }


          }

          /src/com/lusm/spring/test/HelloTest.java

          package com.lusm.spring.test;

          import org.springframework.context.ApplicationContext;
          import org.springframework.context.support.FileSystemXmlApplicationContext;

          public class HelloTest {

              
          public static void main(String[] args) {
                  ApplicationContext ac 
          = new FileSystemXmlApplicationContext(
                          
          "/src/applicationContext.xml");

                  Hello h 
          = (Hello) ac.getBean("hello");

                  System.out.println(h.getStr());
                  h.sayHello();

                  StrValue sv 
          = h.getSv();
                  sv.SayGY();
              }


          }

          執(zhí)行結(jié)果

          log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
          log4j:WARN Please initialize the log4j system properly.

          StrValue 
          class is builded
          setStr
          setSv
          getStr
          你好啊!!!
          你好啊!!!
          getSv
          再見(jiàn)了!!!




          地震讓大伙知道:居安思危,才是生存之道。
          posted on 2007-09-13 23:00 小尋 閱讀(415) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): j2se/j2ee/j2me
          主站蜘蛛池模板: 通辽市| 沙洋县| 育儿| 依安县| 民丰县| 保靖县| 黄浦区| 定安县| 永清县| 河津市| 怀安县| 南皮县| 武清区| 武功县| 平南县| 雷州市| 平和县| 东城区| 和政县| 肥城市| 穆棱市| 荃湾区| 周至县| 平潭县| 平乐县| 东港市| 钟祥市| 芷江| 农安县| 红河县| 浦江县| 永川市| 调兵山市| 旬邑县| 泽普县| 积石山| 乌拉特前旗| 乌恰县| 永胜县| 赫章县| 许昌市|