<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

    本文講解一個不規(guī)范的spring quick start.

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

    2. 進(jìn)入eclipse,F(xiàn)ile - New - Java Project.
    projectname = spring001 ===> Next
    在新建導(dǎo)向的第二頁,是Java Settings, 選擇Libraries -> Add External JARS -> 添加上面2個jar
    finish

    3. 進(jìn)入Package Explorer, 在src下新建一個class.
    Package = com.java114.spring.test
    Name = HelloWordSpring
    再復(fù)選框: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, 內(nèi)容如下
    <?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. 鼠標(biāo)右鍵選擇HelloWordSpring.java, 選擇Run As - Java Applications, 得到結(jié)果:
    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 張辰 閱讀(249) 評論(0)  編輯  收藏 所屬分類: Dr. Oops
    主站蜘蛛池模板: 亚洲AV无码国产精品麻豆天美| 亚洲w码欧洲s码免费| 无码中文在线二区免费| 无码AV动漫精品一区二区免费| 久久久久久精品免费看SSS| 久久久亚洲欧洲日产国码二区| 最近免费mv在线观看动漫 | 亚洲视频在线观看视频| 中文字幕免费观看视频| 久久久久亚洲av成人无码电影| 免费大片av手机看片| 亚洲男人的天堂一区二区| 免费人成再在线观看网站| 亚洲成年人啊啊aa在线观看| 在线观看亚洲AV日韩A∨| 操美女视频免费网站| 亚洲成a人片在线不卡一二三区| 国产精品免费观看久久| 亚洲欧洲国产成人精品| 成人女人A级毛片免费软件| 亚洲毛片基地4455ww| 免费网站看v片在线香蕉| 久久精品国产亚洲av品善| 免费中文字幕一级毛片| 成年免费a级毛片| 亚洲动漫精品无码av天堂| 中文字幕免费视频一| 亚洲人成网站在线观看播放青青| 日韩版码免费福利视频| 亚洲精品日韩一区二区小说| 大陆一级毛片免费视频观看 | 亚洲精品无码久久久影院相关影片 | 免费a级毛片视频| 一级做a爱过程免费视频高清| 在线亚洲精品自拍| 99精品视频在线免费观看 | a一级毛片免费高清在线| 亚洲第一福利网站| 日韩成人毛片高清视频免费看| 亚洲欧洲中文日韩av乱码| 日本免费人成视频在线观看|