<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    佳麗斯 加厚雙人/單人秋冬被子暖冬 羊毛被芯羊毛柔絲被特價(jià)包郵 憂憂魚(yú)冬外穿打底褲女秋冬厚長(zhǎng)褲女褲加絨加厚高腰彈力鉛筆褲靴褲 韓國(guó)代購(gòu)2013新款 韓版秋冬休閑女時(shí)尚磨破口袋衛(wèi)衣韓版學(xué)生裝 潮

    有時(shí),退一步,能一口氣進(jìn)幾步,只是這先退一步需要勇氣和自信。

    用心愛(ài)你,努力工作。

      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      70 隨筆 :: 1 文章 :: 33 評(píng)論 :: 0 Trackbacks

    計(jì)劃用一個(gè)月時(shí)間來(lái)學(xué)習(xí)Spring,在這里把自己的學(xué)習(xí)過(guò)程記錄下來(lái),方便想學(xué)習(xí)Spring的人,也為自己日后復(fù)習(xí)有個(gè)參考。以下通過(guò)一個(gè)簡(jiǎn)單的例子來(lái)先了解下Spring的用法。
    (1)創(chuàng)建一個(gè)java工程,建立如下類(lèi):HelloBean

    package com.ducklyl;

    public class HelloBean {
     private String helloWord;

     public String getHelloWord() {
      return helloWord;
     }

     public void setHelloWord(String helloWord) {
      this.helloWord = helloWord;
     }


    }


    (2)創(chuàng)建Spring配置文件:beans-config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <bean id="helloBean" class="com.ducklyl.HelloBean">
     <property name="helloWord">
        <value>Hello,ducklyl!</value>
     </property>
    </bean>

    </beans>

    (3)導(dǎo)入Spring所需的包:commons-logging.jar,spring.jar 。(日志包和Spring包)
    包下載地址:
    http://www.ziddu.com/download/3555993/Spring.rar.html
    (4)創(chuàng)建測(cè)試類(lèi):SpringDemo.java

    package com.ducklyl;

    import org.springframework.core.io.FileSystemResource;
    import org.springframework.core.io.Resource;
    import org.springframework.beans.factory.BeanFactory;
    import org.springframework.beans.factory.xml.*;


    public class SpringDemo{
     public static void main(String[] args)
     {
      //讀取配置文件
      Resource rs=new FileSystemResource("beans-config.xml");
      //實(shí)例化Bean工廠
      BeanFactory factory=new XmlBeanFactory(rs);
      
      //獲取id="helloBean"對(duì)象
      HelloBean hello=(HelloBean)factory.getBean("helloBean");
      //調(diào)用helloBean對(duì)象getHelloWord()方法
      System.out.println(hello.getHelloWord());
     }

    }

    如果以上配置正確的話,運(yùn)行SpringDemo.java,可以看到輸出結(jié)果:Hello,ducklyl!



        

    posted on 2007-10-21 13:26 王生生 閱讀(2146) 評(píng)論(12)  編輯  收藏 所屬分類(lèi): Spring

    評(píng)論

    # re: Spring學(xué)習(xí)筆記 2007-10-21[未登錄](méi) 2007-10-21 13:41 Evan
    等等我,一起學(xué)  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-10-21 15:13 支持
    不錯(cuò),我也在學(xué)spring,關(guān)注ing,不知樓主用的是什么書(shū)?  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-10-21 21:18 大王
    我現(xiàn)在也在學(xué)spring,一直很奇怪這里<value>Hello,ducklyl!</value>
    好像不能傳參啊??,只能手工設(shè)定??
    IoC到底怎么用啊?  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21[未登錄](méi) 2007-10-21 22:37 helloworld
    我有spring的電子書(shū),不知道怎么傳給你們  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-10-22 08:34 楊?lèi)?ài)友
    spring的電子書(shū)好象是參考手冊(cè),很詳細(xì)很全面字典式的,好象不利于我們這些初學(xué)者。林信良那本《spring 2.0技術(shù)書(shū)冊(cè)》我覺(jué)得很好,但是高手都告訴我,那本書(shū)太簡(jiǎn)單。《spring in Action 2.0》好象還沒(méi)出來(lái)吧,只有1.0的。  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-10-22 23:05 world7th
    為啥我把你的代碼COPY后,運(yùn)行結(jié)果是
    2007-10-22 23:00:16 org.springframework.core.CollectionFactory <clinit>
    信息: JDK 1.4+ collections available
    2007-10-22 23:00:16 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    信息: Loading XML bean definitions from file [D:\java\SpringIocStudy\beans-config.xml]
    Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [D:\java\SpringIocStudy\beans-config.xml]; nested exception is java.io.FileNotFoundException: beans-config.xml (系統(tǒng)找不到指定的文件。)
    Caused by: java.io.FileNotFoundException: beans-config.xml (系統(tǒng)找不到指定的文件。)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:85)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:351)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
    at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
    at demo.SpringDemo.main(SpringDemo.java:14)



    解釋下啊,大俠  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21[未登錄](méi) 2007-10-23 00:52 xmlspy
    回復(fù):world7th

    java.io.FileNotFoundException: beans-config.xml (系統(tǒng)找不到指定的文件。)
      回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21[未登錄](méi) 2007-10-23 08:40 ducklyl
    你路徑放在D:\java\SpringIocStudy\beans-config.xml
    程序應(yīng)該這樣寫(xiě):
    Resource rs=new FileSystemResource("D:\\java\\SpringIocStudy\\beans-config.xml");  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-10-23 10:22 sili
    <bean id="helloBean" class="com.ducklyl.HelloBean"> (1)
    <property name="helloWord"> (2)
    <value>Hello,ducklyl!</value> (3)
    </property>
    </bean>


    能解釋以下1,2,3行的意思嗎  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-10-29 13:17 支持
    <bean id="helloBean" class="com.ducklyl.HelloBean">
    HelloBean helloBean = new HelloBean();
    <property name="helloWord">
    helloBean.setHelloWord("Hello,duckly!");
    這就是依賴(lài)注入,
    原來(lái)由我們程序員做的事情,現(xiàn)在交給容器去做了  回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2007-12-16 22:58 Mation
    初學(xué)Spring,有個(gè)問(wèn)題總是搞不明白,在網(wǎng)上找了很久都沒(méi)有答案
    看到大俠這里有關(guān)于我所遇到的問(wèn)題,相關(guān)方面
    問(wèn)題如下:
    徑放在D:\java\SpringIocStudy\beans-config.xml
    程序應(yīng)該這樣寫(xiě):
    Resource rs=new FileSystemResource
    ("D:\\java\\SpringIocStudy\\beans-config.xml");

    請(qǐng)問(wèn)上面的路徑能用相對(duì)路徑嗎?
    我的QQ504808470
    Mail : mationchen@126.com
      回復(fù)  更多評(píng)論
      

    # re: Spring學(xué)習(xí)筆記 2007-10-21 2008-06-04 14:26 andyjames
    spring in action這本書(shū)建議大家去看看 很不錯(cuò)的書(shū)  回復(fù)  更多評(píng)論
      

    森露2013新款豹紋打底衫 高領(lǐng) 女 長(zhǎng)袖 修身長(zhǎng)袖t恤女 加絨加厚冬 2013春秋新款女裝 潮修身大碼長(zhǎng)袖小西裝外套女 韓版中長(zhǎng)款小西裝 憂憂魚(yú)2013秋冬新款直筒褲女顯瘦長(zhǎng)褲加絨黑色休閑褲修身西褲女褲
    主站蜘蛛池模板: 国产偷国产偷亚洲清高动态图 | 亚洲成a人片在线不卡一二三区| 久久久久久久99精品免费 | 特a级免费高清黄色片| 全黄a免费一级毛片人人爱| 丝袜熟女国偷自产中文字幕亚洲| 国产大陆亚洲精品国产| 又大又粗又爽a级毛片免费看| 精品久久久久久亚洲综合网| 最近中文字幕完整免费视频ww| 午夜国产大片免费观看| 亚洲国产精品成人精品小说| 精品特级一级毛片免费观看| 亚洲AV无码之日韩精品| 亚洲综合中文字幕无线码| 成人免费看吃奶视频网站| 91精品国产亚洲爽啪在线影院| 四虎影视成人永久免费观看视频| 亚洲无删减国产精品一区| 成人精品综合免费视频| 中文字幕亚洲图片| 一级特黄aa毛片免费观看| 亚洲性色高清完整版在线观看| 两个人的视频高清在线观看免费| 亚洲av无码片vr一区二区三区 | 亚洲伊人久久大香线蕉苏妲己| aⅴ免费在线观看| 亚洲精品免费视频| 成年人免费的视频| 亚洲色图黄色小说| 成年丰满熟妇午夜免费视频| 日产久久强奸免费的看| 亚洲αv在线精品糸列| 国产一级高青免费| 亚洲国产成人久久综合区| 免费福利电影在线观看| 亚洲精品白浆高清久久久久久| 又大又硬又爽又粗又快的视频免费 | 亚洲视频在线观看免费视频| 亚洲自偷自偷在线成人网站传媒| 亚洲综合免费视频|