軟件版本:
Eclipse:eclipse-jee-neon-3-win32-x86_64
JDK: 1.8
Openfire: 4.1.5
- 下載源碼
圖1.png
選擇openfire_src_4_1_5.zip下載
- 配置Eclipse項(xiàng)目戈稿。把下載好的 openfire_src_4_1_5.zip 壓縮包直接解壓到Eclipse的工作目錄(E:\eclipse\openfire),結(jié)構(gòu)如下:
圖2.png
- 打開(kāi)openfire_src,目錄如下
圖3.png
將圖中的三個(gè)html文件刪除。
- 把openfire_src/build/eclipse/下的三個(gè)文件夾復(fù)制到openfire_src/目錄下柜砾。
圖4.png
圖5.png
- 把openfire_src目錄下的classpth文件趁矾、project文件、settings文件夾修改成Eclipse工程配置文件格式聘殖,重命名為在每個(gè)原有的名字上加上一個(gè)點(diǎn)芹关,即.classpth良拼、.project、.settings充边。如下圖所示:
圖6.png
注意:在windows下面不能直接重命名,需要在dos下面操作常侦,即進(jìn)入相應(yīng)的目錄執(zhí)行rename classpth .classpth即可浇冰,其它兩個(gè)文件執(zhí)行一樣的操作。
圖7.png
- 打開(kāi)Eclipse聋亡,選擇 File –> Import… –> Existing Projects into Workspace 選擇E:\eclipse\openfire\openfire_src 導(dǎo)入即可
圖8.png
- 導(dǎo)入后目錄結(jié)構(gòu)如下(因源文件夾太多肘习,截圖無(wú)法截全)
圖9.png
- 使用ANT進(jìn)行工程的編譯。Eclipse中Window->Show View->Ant坡倔,顯示出Ant窗口漂佩,單擊右鍵,在彈出的快捷菜單中選擇Add Buildfiles罪塔,在彈出的對(duì)話框中投蝉,展開(kāi)openfire/build文件夾,選擇build目錄下的build.xml征堪,點(diǎn)擊OK瘩缆,接下來(lái)在Ant視圖中將Openfire XMPP Server右鍵選擇Run As->Ant Build,等待片刻佃蚜,在控制臺(tái)中顯示“BUILD SUCCESSFUL” 那么就表示編譯成功庸娱。
圖10.png
圖11.png
- 設(shè)置啟動(dòng)項(xiàng)目着绊。點(diǎn)擊openfire項(xiàng)目,在菜單欄中選擇Run->Run Configurations彈出一個(gè)對(duì)話框熟尉,在左側(cè)菜單中右鍵點(diǎn)擊Java Application归露,選擇New創(chuàng)建啟動(dòng)配置。
圖12.png
- 其中 Name隨便設(shè)置斤儿,Main class設(shè)置為"org.jivesoftware.openfire.starter.ServerStarter",點(diǎn)擊應(yīng)用剧包。
圖13.png
- 點(diǎn)擊進(jìn)入Arguments選項(xiàng)卡,在上面那個(gè)框(VM arguments:)中填寫(xiě)
-DopenfireHome="${workspace_loc:openfire}/target/openfire"
其中${workspace_loc:openfire} 中的 openfire要根據(jù)你的項(xiàng)目名來(lái)進(jìn)行同步修改,點(diǎn)擊Apply應(yīng)用雇毫。
圖14.png
- 點(diǎn)擊進(jìn)入Classpath選項(xiàng)卡玄捕,選中User Entries,然后點(diǎn)擊右側(cè)的Advanced按鈕棚放,會(huì)彈出一個(gè)小框枚粘,選擇Add Folders,單擊OK飘蚯。
選擇 openfire\src\i18n點(diǎn)OK 按鈕將這個(gè)文件夾加入到Classpath選項(xiàng)卡中
選擇 openfire\src\resources 目錄也加到 Classpath選項(xiàng)卡中
點(diǎn)擊Apply應(yīng)用馍迄。
圖15.png
圖16.png
- 點(diǎn)擊進(jìn)入Common選項(xiàng)卡中,勾選Run復(fù)選框局骤,點(diǎn)擊Apply應(yīng)用攀圈。
圖17.png
- 點(diǎn)擊Run運(yùn)行。 程序正常運(yùn)行結(jié)果如下峦甩。
圖18.png
- 在瀏覽器中輸入http://127.0.0.1:9090運(yùn)行后顯示結(jié)果如下
圖19.png
- 這是由文件路徑所導(dǎo)致的赘来,解決方法: 點(diǎn)擊進(jìn)入Classpath選項(xiàng)卡,選中User Entries凯傲,然后點(diǎn)擊右側(cè)的Advanced按鈕犬辰,會(huì)彈出一個(gè)小框,選擇Add Folders冰单,單擊OK幌缝。
選擇 openfire\src\resources\jar 目錄也加到 Classpath選項(xiàng)卡中
點(diǎn)擊Apply應(yīng)用。
圖20.png