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

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

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

    posts - 32,comments - 8,trackbacks - 0

    本文講解一個不規范的spring quick start.

    1. 下載spring的插件包,什么版本之類的不用管了。反正能用。
    spring.jar http://www.boxcn.net/shared/yg306zac1h
    common-logging.jar http://www.boxcn.net/shared/ix93ziqljv

    2. 進入eclipse,File - New - Java Project.
    projectname = spring001 ===> Next
    在新建導向的第二頁,是Java Settings, 選擇Libraries -> Add External JARS -> 添加上面2個jar
    finish

    3. 進入Package Explorer, 在src下新建一個class.
    Package = com.java114.spring.test
    Name = HelloWordSpring
    再復選框:public static void main(String[] args) 鉤上

    4. 在HelloWordSpring.java 輸入以下的代碼
    package com.java114.spring.test;

    import org.springframework.beans.factory.BeanFactory;
    import org.springframework.beans.factory.xml.XmlBeanFactory;
    import org.springframework.core.io.ClassPathResource;
    import org.springframework.core.io.Resource;

    public class HelloWordSpring
    {
        
    private String msg;

        
    public void setMsg(String msg)
        {
            
    this.msg = msg;
        }

        
    public void sayHello()
        {
            System.out.println(msg);
        }

        
    public static void main(String[] args)
        {
            Resource res 
    = new ClassPathResource("com/java114/spring/test/bean.xml");
            BeanFactory factory 
    = new XmlBeanFactory(res);
            HelloWordSpring hello 
    = (HelloWordSpring) factory.getBean("helloBean");
            hello.sayHello();
        }

    }

    5. 在和HelloWordSpring.java 相同目錄下面,再新建一個xml文件,名字是bean.xml, 內容如下
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
     
    <bean id="helloBean" class="com.java114.spring.test.HelloWordSpring">
      
    <property name="msg" value="simple spring demo"/>
     
    </bean>
    </beans>
    為什么這樣寫,我也不知道,不管他。

    6. 鼠標右鍵選擇HelloWordSpring.java, 選擇Run As - Java Applications, 得到結果:
    2010-6-16 21:39:47 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    信息: Loading XML bean definitions from class path resource [com/java114/spring/test/bean.xml]
    simple spring demo

    posted on 2010-06-16 20:13 張辰 閱讀(258) 評論(0)  編輯  收藏 所屬分類: Dr. Oops
    主站蜘蛛池模板: 成人嫩草影院免费观看| 免费无码肉片在线观看| 亚洲男人天堂2020| 亚洲第一第二第三第四第五第六| 一二三四免费观看在线视频中文版| 亚洲理论片在线观看| 亚洲三级在线免费观看| 亚洲精品第五页中文字幕| 91高清免费国产自产| 亚洲人和日本人jizz| 九九九精品成人免费视频| 亚洲熟妇成人精品一区| 永久免费AV无码网站在线观看| 日韩国产精品亚洲а∨天堂免| 成人亚洲综合天堂| 久久伊人久久亚洲综合| 免费国产黄网站在线观看可以下载 | 亚洲日本va午夜中文字幕久久| 看Aⅴ免费毛片手机播放| 亚洲综合久久夜AV | 久久香蕉国产线看免费| 亚洲影视自拍揄拍愉拍| 亚洲成AV人在线观看网址| 中国性猛交xxxxx免费看| 亚洲精品中文字幕无乱码| 日韩高清在线免费观看| 国产福利免费视频| 在线A级毛片无码免费真人| 亚洲aⅴ无码专区在线观看春色 | 免费播放在线日本感人片| 亚洲国产第一页www| 成人免费一区二区三区 | 亚洲成av人片天堂网| 日本高清在线免费| 国产午夜亚洲精品不卡电影| 国产亚洲高清不卡在线观看| 国产91色综合久久免费| 一级免费黄色大片| 亚洲国产日产无码精品| 亚洲国产精品国产自在在线| 18成禁人视频免费网站|