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

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

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

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

    有時,退一步,能一口氣進幾步,只是這先退一步需要勇氣和自信。

    用心愛你,努力工作。

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      70 隨筆 :: 1 文章 :: 33 評論 :: 0 Trackbacks

    計劃用一個月時間來學習Spring,在這里把自己的學習過程記錄下來,方便想學習Spring的人,也為自己日后復習有個參考。以下通過一個簡單的例子來先了解下Spring的用法。
    (1)創(chuàng)建一個java工程,建立如下類: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)導入Spring所需的包:commons-logging.jar,spring.jar 。(日志包和Spring包)
    包下載地址:
    http://www.ziddu.com/download/3555993/Spring.rar.html
    (4)創(chuàng)建測試類: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");
      //實例化Bean工廠
      BeanFactory factory=new XmlBeanFactory(rs);
      
      //獲取id="helloBean"對象
      HelloBean hello=(HelloBean)factory.getBean("helloBean");
      //調用helloBean對象getHelloWord()方法
      System.out.println(hello.getHelloWord());
     }

    }

    如果以上配置正確的話,運行SpringDemo.java,可以看到輸出結果:Hello,ducklyl!



        

    posted on 2007-10-21 13:26 王生生 閱讀(2132) 評論(12)  編輯  收藏 所屬分類: Spring

    評論

    # re: Spring學習筆記 2007-10-21[未登錄] 2007-10-21 13:41 Evan
    等等我,一起學  回復  更多評論
      

    # re: Spring學習筆記 2007-10-21 2007-10-21 15:13 支持
    不錯,我也在學spring,關注ing,不知樓主用的是什么書?  回復  更多評論
      

    # re: Spring學習筆記 2007-10-21 2007-10-21 21:18 大王
    我現在也在學spring,一直很奇怪這里<value>Hello,ducklyl!</value>
    好像不能傳參啊??,只能手工設定??
    IoC到底怎么用?。?nbsp; 回復  更多評論
      

    # re: Spring學習筆記 2007-10-21[未登錄] 2007-10-21 22:37 helloworld
    我有spring的電子書,不知道怎么傳給你們  回復  更多評論
      

    # re: Spring學習筆記 2007-10-21 2007-10-22 08:34 楊愛友
    spring的電子書好象是參考手冊,很詳細很全面字典式的,好象不利于我們這些初學者。林信良那本《spring 2.0技術書冊》我覺得很好,但是高手都告訴我,那本書太簡單?!秙pring in Action 2.0》好象還沒出來吧,只有1.0的。  回復  更多評論
      

    # re: Spring學習筆記 2007-10-21 2007-10-22 23:05 world7th
    為啥我把你的代碼COPY后,運行結果是
    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 (系統找不到指定的文件。)
    Caused by: java.io.FileNotFoundException: beans-config.xml (系統找不到指定的文件。)
    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)



    解釋下啊,大俠  回復  更多評論
      

    # re: Spring學習筆記 2007-10-21[未登錄] 2007-10-23 00:52 xmlspy
    回復:world7th

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

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

    # re: Spring學習筆記 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行的意思嗎  回復  更多評論
      

    # re: Spring學習筆記 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!");
    這就是依賴注入,
    原來由我們程序員做的事情,現在交給容器去做了  回復  更多評論
      

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

    請問上面的路徑能用相對路徑嗎?
    我的QQ504808470
    Mail : mationchen@126.com
      回復  更多評論
      

    # re: Spring學習筆記 2007-10-21 2008-06-04 14:26 andyjames
    spring in action這本書建議大家去看看 很不錯的書  回復  更多評論
      

    森露2013新款豹紋打底衫 高領 女 長袖 修身長袖t恤女 加絨加厚冬 2013春秋新款女裝 潮修身大碼長袖小西裝外套女 韓版中長款小西裝 憂憂魚2013秋冬新款直筒褲女顯瘦長褲加絨黑色休閑褲修身西褲女褲
    主站蜘蛛池模板: 无忧传媒视频免费观看入口| 免费在线观看毛片| 天黑黑影院在线观看视频高清免费 | 好爽好紧好大的免费视频国产 | 亚洲XX00视频| 影音先锋在线免费观看| 99免费观看视频| 免费一区二区无码东京热| 免费人人潮人人爽一区二区| 99久久国产亚洲综合精品| 亚洲性天天干天天摸| 亚洲日韩欧洲乱码AV夜夜摸| 亚洲性在线看高清h片| 又粗又黄又猛又爽大片免费 | 亚洲www77777| 亚洲av无码不卡久久| 亚洲白嫩在线观看| 亚洲视频在线观看免费| 久久青青草原亚洲AV无码麻豆| 亚洲一区无码精品色| 亚洲AV之男人的天堂| 免费大黄网站在线观看| 国产男女猛烈无遮挡免费网站| 免费无码又爽又高潮视频| 成年男女男精品免费视频网站| 91在线视频免费看| 大地资源二在线观看免费高清| 中文字幕无码视频手机免费看| 免费国产作爱视频网站| 久久电影网午夜鲁丝片免费| 免费一本色道久久一区| 四虎影视www四虎免费| 韩国欧洲一级毛片免费| 免费人成视网站在线观看不卡| 亚洲第一页综合图片自拍| 亚洲国产一区视频| 日日噜噜噜噜夜夜爽亚洲精品 | 狠狠躁狠狠爱免费视频无码| 国产精品永久免费视频| 免费国产成人α片| 成人免费大片免费观看网站|