<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 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
      51 Posts :: 25 Stories :: 59 Comments :: 0 Trackbacks

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

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

    整理一下我目前可能會(huì)用到的模塊, 對(duì)于那些現(xiàn)在根本用不到的冬冬還是等有時(shí)間再研究吧!

    第一個(gè)當(dāng)然是最經(jīng)典的HelloWorld 了 , 呵呵,簡(jiǎn)單,但是說(shuō)明了原理.

    定義一個(gè)服務(wù)接口

    package? test.helloworld;

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

    }

    下面是其實(shí)現(xiàn):

    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;
    ?? }

    }

    然后就是測(cè)試 IoC 的測(cè)試代碼:

    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 >

    呵呵就這么簡(jiǎn)單,實(shí)現(xiàn)了 greeting 屬性的 Ioc.

    這是Spring 兩大基本支柱其一的工作原理, 關(guān)于AoP的內(nèi)容,在這里不作討論,因?yàn)楝F(xiàn)在我使用AoP的地方不是很多,簡(jiǎn)單的應(yīng)用是很簡(jiǎn)單的啦.^_^.

    下面一篇我們來(lái)看看 在spring包裝下的jdbc訪(fǎng)問(wèn). 詳細(xì)情況也可以參考這里

    posted on 2006-05-22 14:13 冰雨 閱讀(1905) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Spring

    JSF中文技術(shù)文摘
    主站蜘蛛池模板: 久久一区二区三区免费| 国产成人免费在线| 亚洲欧洲自拍拍偷午夜色无码| 午夜免费福利视频| 亚洲日韩国产AV无码无码精品| 亚洲国产精品成人久久蜜臀| 99爱免费观看视频在线| 色偷偷噜噜噜亚洲男人| 国产亚洲日韩在线三区| 国产v精品成人免费视频400条| 国产精品亚洲专区在线播放| 亚洲AV日韩AV鸥美在线观看| 日本久久久免费高清| 三级网站免费观看| 亚洲欧美国产欧美色欲| 亚洲国产成人高清在线观看| 免费无码又爽又刺激高潮| 特级做A爰片毛片免费看无码 | 少妇亚洲免费精品| 亚洲人成网www| 四虎AV永久在线精品免费观看| 久草免费福利资源站| 国产亚洲男人的天堂在线观看| 亚洲成熟xxxxx电影| 免费大黄网站在线观| 国产成人免费爽爽爽视频| 三上悠亚在线观看免费| 亚洲国产精品无码久久久秋霞1| 亚洲av无码片在线播放| 亚洲AV永久无码精品一区二区国产 | 国产精品免费小视频| 99精品视频在线免费观看| 一个人看的www视频免费在线观看 一个人看的免费观看日本视频www | 91香蕉视频免费| 久久国产精品成人免费| 亚洲欧美在线x视频| 天天爽亚洲中文字幕| 亚洲高清视频在线播放| 国产成A人亚洲精V品无码性色| 亚洲国产成人久久综合野外| 日韩视频在线免费观看|