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

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

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

    Ryan's Java world!

    something about Java and opensource!

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      51 Posts :: 25 Stories :: 59 Comments :: 0 Trackbacks

    By : icess ,我的部落格 http://blog.matrix.org.cn/page/icess

    在考試前匆匆看了一遍Spring in Action 也沒有記錄什么,考試結束了,要抓緊時間整理一下.要不然就忘了.^_^:

    整理一下我目前可能會用到的模塊, 對于那些現在根本用不到的冬冬還是等有時間再研究吧!

    第一個當然是最經典的HelloWorld 了 , 呵呵,簡單,但是說明了原理.

    定義一個服務接口

    package? test.helloworld;

    public?interface? GreetingService?{
    ?? public?void? sayGreeting();

    }

    下面是其實現:

    package? test.helloworld;

    public?class? GreetingServiceImpl? implements? GreetingService?{

    ?? private? String?greeting;
    ?? public? GreetingServiceImpl()?{}
    ?? public? GreetingServiceImpl(String?greeting)?{
    ???? this .greeting?=?greeting;
    ?? }
    ?? public?void? sayGreeting()?{
    ???? //??Auto-generated?method?stub
    ???? System.out.println(greeting);
    ?? }
    ??
    ?? public?void? setGreeting(String?greeting)?{
    ???? this .greeting?=?greeting;
    ?? }

    }

    然后就是測試 IoC 的測試代碼:

    package? test.helloworld;


    import? org.springframework.beans.factory.BeanFactory;
    import? org.springframework.beans.factory.xml.XmlBeanFactory;
    import? org.springframework.context.ApplicationContext;
    import? org.springframework.context.support.ClassPathXmlApplicationContext;
    import? org.springframework.core.io.FileSystemResource;

    public?class? HelloApp?{

    ?? /**
    ??? *? @param? args
    ??? */
    ?? public?static?void? main(String[]?args)?{
    ???? //?TODO?Auto-generated?method?stub
    //????BeanFactory?factory;
    //????factory?=?new?XmlBeanFactory(new?FileSystemResource("src/test/helloworld/hello.xml"));
    ???? //?使用不同的方法得到bean.?(BeanFactory?or?ApplicationContext)
    ???? ApplicationContext?context?=? new? ClassPathXmlApplicationContext( "test/helloworld/hello.xml" );
    ????
    ????
    ???? GreetingService?greetingService?=?(GreetingService)?context.getBean( "greetingService" );
    //????GreetingService?greetingService?=?(GreetingService)?factory.getBean("greetingService");
    ???? greetingService.sayGreeting();
    ?? }

    }

    還有重要的配置文件如下:hello.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 = "greetingService"

    class = "test.helloworld.GreetingServiceImpl" >

    < property name = "greeting" >

    < value > ice rain ! </ value >

    </ property >

    </ bean >

    </

    beans >

    呵呵就這么簡單,實現了 greeting 屬性的 Ioc.

    這是Spring 兩大基本支柱其一的工作原理, 關于AoP的內容,在這里不作討論,因為現在我使用AoP的地方不是很多,簡單的應用是很簡單的啦.^_^.

    下面一篇我們來看看 在spring包裝下的jdbc訪問. 詳細情況也可以參考這里

    posted on 2006-05-22 14:13 冰雨 閱讀(1918) 評論(0)  編輯  收藏 所屬分類: Spring

    JSF中文技術文摘
    主站蜘蛛池模板: 久久电影网午夜鲁丝片免费| 久久av免费天堂小草播放| 99久热只有精品视频免费观看17| 国产成人精品日本亚洲专区| 青娱乐在线视频免费观看| 国产一区二区三区在线观看免费 | 久久亚洲国产中v天仙www| 一个人看的www免费高清| 亚洲国产综合人成综合网站| 无码日韩人妻AV一区免费l| 国产免费小视频在线观看| 黄色大片免费网站| 亚洲熟伦熟女新五十路熟妇| 一级毛片试看60分钟免费播放| 国产精品亚洲w码日韩中文| 无码日韩人妻AV一区免费l| 亚洲精品乱码久久久久久中文字幕| 99re6在线视频精品免费| 亚洲伦理一区二区| 日本最新免费网站| 亚洲一本到无码av中文字幕| 国产精品无码一二区免费 | 亚洲熟妇少妇任你躁在线观看| 在线a毛片免费视频观看| 另类专区另类专区亚洲| 亚洲成人国产精品| 免费看男人j放进女人j免费看| 亚洲精品美女在线观看| 四虎成人免费网址在线| 特黄特色的大片观看免费视频| 国产亚洲综合色就色| 18女人腿打开无遮掩免费| 精品国产成人亚洲午夜福利| 免费国产成人高清在线观看麻豆| 亚洲免费日韩无码系列| 亚洲成熟xxxxx电影| 四虎www成人影院免费观看| 一级成人a免费视频| 亚洲婷婷在线视频| 亚洲国产综合人成综合网站| 最近中文字幕大全中文字幕免费|