隨筆-26  評論-44  文章-20  trackbacks-0
          public class Table {
              String tableName;
              String mainPropertyName;
              static int count=1;
              static DBExcute dbExcute=(DBExcute)new ClassPathXmlApplicationContext("applicationContext.xml").getBean("dbExcute");
             
              Table(String tableName,String mainPropertyName){
                  this.tableName=tableName;
                  this.mainPropertyName=mainPropertyName;
                  System.out.println("construct table"+(count++)+" use:"+dbExcute);
              }
                  .............
                  .............
               public static void main(String []dsf){
               new Table("user","1");
            }
          }

          如上只new Table(..)一次:
          結果卻是:
          construct table1 use:null
          construct table2 use:null
          construct table3 use:null
          construct table4 use:null
          construct table5 use:null
          construct table6 use:com.yijia_ctgu.DB.DBExcute@535b58


          奇怪中。。。。。。。


          明白了,spring容器初始化的時候,初始化dbDAO bean會生成五個table,可能是先初始化,后才賦值給dbExcute,所以剛開始的五個都是null.



          開機 2008-11-05 14:45 發表評論

          文章來源:http://www.aygfsteel.com/yijia/archive/2008/11/05/238818.html
          posted on 2009-10-20 09:32 開機 閱讀(61) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 仁寿县| 锡林郭勒盟| 卫辉市| 调兵山市| 双峰县| 鄂托克前旗| 天祝| 松阳县| 莎车县| 兰溪市| 自治县| 象山县| 夏津县| 诸城市| 大庆市| 阿荣旗| 融水| 周至县| 忻城县| 新宁县| 南康市| 灵石县| 商洛市| 遂平县| 定襄县| 开平市| 阿尔山市| 临桂县| 新营市| 孝昌县| 灵台县| 桃源县| 阿坝| 荆州市| 田林县| 荔波县| 云阳县| 娱乐| 隆化县| 公主岭市| 弋阳县|