国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Spring源碼研究--下載-編譯-導(dǎo)入eclipse-驗(yàn)證

2019-11-14 23:18:22
字體:
供稿:網(wǎng)友
SPRing源碼研究--下載-編譯-導(dǎo)入eclipse-驗(yàn)證 2015-03-15 21:50 by 逍遙游xj, ... 閱讀, ... 評(píng)論, 收藏, 編輯

一,環(huán)境配置

操作系統(tǒng):Unbutu14.04LTS

JDK: 1.8.0_40

git: 1.9.1

gradle: 2.2.1

二,源碼下載-編譯-導(dǎo)入eclipse-驗(yàn)證

1,下載

使用git直接clone Spring源碼到本地:git clone git://github.com/SpringSource/spring-framework.git

2,編譯

編譯過程,這里所謂的編譯是通過gradle工具編譯Spring-framework的項(xiàng)目文件,主要干的事情就是下載Spring各個(gè)模塊依賴的jar包,這個(gè)過程一般情況下非常慢,可能是因?yàn)橘Y源都在墻外,并且可能出現(xiàn)jar包很久下載不下來的情況,這時(shí)候直接ctrl+c退出編譯命令后再次執(zhí)行命令,對(duì)于已經(jīng)下載下來的以來包不會(huì)再次下載,所以編譯的過程相當(dāng)與可以斷線重連的效果。

①進(jìn)入源碼目錄執(zhí)行:gradle eclipse -x :eclipse (我整整花費(fèi)了1上午才編譯通過)②,執(zhí)行g(shù)radle install 這個(gè)具體神馬作用我還不清楚,但是不執(zhí)行這個(gè)命令導(dǎo)入①編譯后的代碼進(jìn)eclipse后會(huì)有一堆build path error,猜想應(yīng)該是將步驟1中down下來的依賴存入gradle本地倉庫以便于項(xiàng)目查找使用相關(guān)依賴。

③,直接通過eclipse的import到入Spring-framework源碼目錄

groovy這個(gè)項(xiàng)目可能會(huì)有方法找不到,主要原因時(shí)你的eclipse沒有裝Groovy插件,裝上后clean下項(xiàng)目就OK了

④,驗(yàn)證

寫一個(gè)簡單的測(cè)試項(xiàng)目,簡單的IoC調(diào)用功能,依賴spring-context項(xiàng)目

a),TestSpring.java
 1 import org.springframework.context.applicationContext; 2 import org.springframework.context.support.ClassPathxmlApplicationContext; 3  4 import com.test.bean.Lover; 5  6  7 public class TestSpring { 8     /** 9      * @param args10      */11     @SuppressWarnings("resource")12     public static void main(String[] args) {13         ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");14         Lover p = ctx.getBean("lover",Lover.class);15         p.info();16     }17 18 }

b),Lover.java

 1 package com.test.bean; 2  3 public class Lover { 4      5     private String name; 6     private int age; 7      8     public String getName() { 9         return name;10     }11     public void setName(String name) {12         this.name = name;13     }14     public int getAge() {15         return age;16     }17     public void setAge(int age) {18         this.age = age;19     }20     public void info(){21         System.out.println("Spring is a best lover fro you~~~");22     }23 }

c),bean.xml

 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans 3  xmlns="http://www.springframework.org/schema/beans" 4  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5  xmlns:context="http://www.springframework.org/schema/context" 6  xsi:schemaLocation="http://www.springframework.org/schema/beans  7                     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 8                     http://www.springframework.org/schema/context 9                     http://www.springframework.org/schema/context/spring-context-2.5.xsd10                     ">11                     12 <bean id="lover" class="com.test.bean.Lover" scope="prototype"></bean>13 14 </beans>

三,總結(jié)

  本文主要小結(jié)了Spring源碼的下載(github),編譯(gradle),導(dǎo)入eclipse的過程,最后簡單測(cè)試了導(dǎo)入eclipse后的SpringIoC模塊的功能。從此開啟了Spring源碼深入研究之路。

本文版權(quán)所有,轉(zhuǎn)載請(qǐng)注明出處


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 遵化市| 资源县| 开阳县| 海原县| 栾川县| 玉山县| 越西县| 宽城| 东乌| 东阿县| 桦南县| 延寿县| 敦煌市| 咸宁市| 濉溪县| 论坛| 玉门市| 霸州市| 南丰县| 西昌市| 长阳| 阜新| 昆明市| 区。| 沙湾县| 察隅县| 蒙山县| 平陆县| 成都市| 曲阜市| 鹤壁市| 温泉县| 黎平县| 馆陶县| 秭归县| 新丰县| 天门市| 仙游县| 九龙城区| 永和县| 紫阳县|