<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
    主站蜘蛛池模板: 一道本不卡免费视频| 亚洲1234区乱码| 免费看一级高潮毛片| 四虎永久精品免费观看| 57pao国产成永久免费视频| 日本午夜免费福利视频| 亚洲av无码片vr一区二区三区| 久青草视频97国内免费影视| 国产成人精品亚洲精品| 国产精品亚洲精品观看不卡| 一个人看的www免费高清| 亚洲精品视频免费观看| 四虎国产精品免费永久在线| 亚洲精品乱码久久久久久| 99久久国产精品免费一区二区| 狠狠久久永久免费观看| 久久精品国产亚洲av高清漫画| 6080午夜一级毛片免费看| 亚洲一级毛片中文字幕| 日韩在线视频免费看| 色婷婷综合缴情综免费观看| 亚洲精品午夜无码电影网| 久久大香伊焦在人线免费| 亚洲国产高清美女在线观看| 高清国语自产拍免费视频国产| 国产亚洲精品2021自在线| 亚洲日韩国产精品第一页一区| 中文字幕无码日韩专区免费| 亚洲冬月枫中文字幕在线看| 国产精品jizz在线观看免费| 国产人成亚洲第一网站在线播放| 99re免费视频| 日本久久久久亚洲中字幕| 成人a视频片在线观看免费| 精品丝袜国产自在线拍亚洲| 无码不卡亚洲成?人片| 国产羞羞的视频在线观看免费| 一本色道久久88亚洲精品综合| 精品久久8x国产免费观看| 亚洲第一街区偷拍街拍| 国产成人麻豆亚洲综合无码精品|