Eclipse中SVN版本控制插件的安裝和使用

這裏介紹Eclipse的SVN Plugin,叫做Subclipse,官方網站的下載地址在http://subclipse.tigris.org/ ,也提供了update site http://subclipse.tigris.org/update
Eclipse 的使用者可以通過Eclipse的插件自動下載和更新功能來安裝這個插件,在Eclipse的菜單中選擇Help->Software Updates->Find and Install-> Search for new features to install ->New Remote Site。URL中就輸入http://subclipse.tigris.org/update ,Eclipse就會自已安裝上了.

安裝完成後,在Eclipse的plugins中就會多了5個包,命名爲org.tigris.subversion.*的都應該是了。打開 Eclipse,window->show view窗口中多了一個SVN文件夾,到此就證明svn插件成功的安裝上了。具體的使用方法,在Eclipse的Help中有詳細的幫助 Subclipse - Subversion Eclipse Plugin,教你一步一步的使用SVN的客戶端了。如果你對subversion想進行深入的瞭解,那麼看看help中的Version Control with Subversion一定有所收穫,通過本人的觀察,這份文檔和sbuversion安裝文件中提供的官方文檔一樣,這裏看起來就更舒服些了。

 

 

 

以前提到過SVN版本控制器和客戶端的安裝和配置,這裏再在說一下在編譯器中怎麼使用SVN,使其既可以單獨使用,也可以配合SVN客戶端一起使用。由於編譯器種 類衆多,插件種類也不同,這裏只簡單介紹下Eclipse的插件安裝。我用的版本是Eclipse3.2.2+MyEclipse_5.1.1,由於本身 只有CVS而沒有集成SVN,所以要想使用SVN做版本控制只好裝一個Eclipse插件Subclipse,Subclipse的詳細安裝過程在其官方 網站 http://subversion.tigris.org寫的很清楚,還帶配圖,我就直接copy了:

一、Install Subclipse in Eclipse 3.x(安裝)

Step 1:

Begin the installation from the Eclipse Help menu item.

Step 2:

This screenshot show the screen as it initially comes up. In this case you will need to change the radio button to indicate that this is a new install.

Step 3:

This screen will vary depending on the features you have installed already. You want to click on the New Remote Site button. If you are behind a proxy and the Eclipse install mechanism does not work, then you can download a zipped version of the update site and then click the New Local Site button instead.

Step 4:

This screen is showing the New Remote Site dialog, filled in with the correct information to install Subclipse

Name: Subclipse 1.2.x (Eclipse 3.2+)
URL: http://subclipse.tigris.org/update_1.2.x

Name: Subclipse 1.0.x (Eclipse 3.0/3.1)
URL: http://subclipse.tigris.org/update_1.0.x

Step 5:

When you first come back to this screen, the site you added will NOT be selected. Be sure to select it before clicking Next.

Step 6:

This next screen shows all of the features that are available to install.

Step 7:

Click the button to accept the license agreement.

Step 8:

Confirm the install location

Step 9:

There is an Eclipse preference to turn off this next dialog. I have never seen a signed feature. Not even Eclipse.org nor IBM sign their features.

Step 10:

Just a screenshot of the in-process installation.

Step 11:

Eclipse needs to be restarted after installing Subclipse.

Step 12:

Finally, after restarting Eclipse, the first thing you will typically want to do is open the Subclipse Repository perspective where you can define your repositories. Be sure to also check the online help as well as the Subclipse preferences located under Team -> SVN.

OK

到此你的插件已經安裝完畢了,說明一下,在Step 5中選擇的是在線安裝,也可以在http://subversion.tigris.org/servlets /ProjectDocumentList?folderID=91下載後進行本地安裝,本地安裝選擇New Local Sit...,然後找到解壓出來的那個文件夾,後面的都一樣了。

卸載的方法也很簡單,也是點擊 Help => Software Updates => Manage Configuration

按上圖操作就可以卸載了。

二、Use Subclipse in Eclipse 3.x(使用)

先向版本庫中加入一個Eclipse工程,我這裏是隨便搭建的 一個WEB工程 SVNtest ,將它導入版本庫svn://localhost/ts(這使用本機裝的版本庫,其他機器就要打ip地址,之前說過)。導入後用版本庫瀏覽器找到你導入的 工程目錄,把其下WebRoot/WEB-INF/classes目錄刪掉(注意:不刪出以後會報錯,原因後面再討論)這些初始化的操作都用客戶端工具完 成的,畢竟插件的功能還不是那麼強大。

做好以上的準備後打開Eclipse編譯器,點擊編譯器右上角的Open Perspective 打開SVN資源庫界面,新建一個資源庫

選擇資源庫的位置,這裏我們就用剛纔搭好的 svn://localhost/ts 作爲工程目錄,點擊Finish後如果成功則會看到版本服務器中工程的樹形結構了(可能需要用戶密碼驗證)。在svn://localhost/ts 根目錄上點右鍵,選擇“驗出”(英文版的可能叫 Check Out),在彈出窗口中選擇“作爲空間的項目驗出”,下邊的項目名稱隨便叫,我這裏還是用 SVNtest 作爲項目名稱。

一切沒有問題了點擊Finish。之後它就會從服務器上把工程下到你本地了。好啦,來到Eclipse編輯欄會發現剛纔下的工程文件都會帶有SVN版本控制標記了,再去Workspace看看,也會發現下載的工程文件夾,並且也有控制標記。 而且裏我們會發現在SVN控制下的文件多出來一個Team選單,打開一看原來就是一個客戶端工具呀,提交,更新,同步,合併,切換……我們再熟悉不過了,自己試試吧 ^_^。

順便說一下剛纔爲什麼要刪除class目錄,起初我沒有刪掉它,更改提交沒有問題,但在更新時總是報錯:……Working copy not locked; this is probably a bug, please report svn:…… ,提示就是class目錄下的.svn有毛病,到http://www.tigris.org查找解決方法,有一段描述:

This message is coming straight out of the Subversion library, so technically it is Subversion asking you to report the problem to them. This error message is kind of their general error message when something really unexpected happens. In the case of Eclipse, the problem is almost always one specific thing. The problem is that your Eclipse build folder was versioned and added to your repository. What happens is that when Eclipse does a full build it will delete everything in this folder, including the ".svn" metadata folder. When Subversion cannot find this folder it issues the above error.
The solution is to delete this folder from your repository, which you can do from the SVN Repositories view. Then try deleting the folder from your working copy and perforiming an update. You might need to checkout your project again. Once you have a valid project again, be sure to add the build folder to the svn:ignore property of its parent folder so that the problem does not happen again.
If this is not your problem, then as best as you can try to figure out what might have led up to having this problem and report it on th Subversion [email protected] mailing list

大意:重新部署工程時會將文件夾WEB-INF/classes下的內容全刪了,包括".svn"這個文件夾,從面導致SVN找不到這個文件夾的信息,於是報錯。 解決的方法是在SVN倉庫內將classes下的內容清空,然後在確保本地工程已完全提交的情況下,將本地工程包括文件刪除,再從SVN倉庫中重新取出。 導致此問題的原因善不明確,估計是往這個文件夾手動添加了文件。

安裝方面就介紹到此吧,如果有什麼問題在聯繫我吧。

相關資源

Subversion http://subversion.tigris.org/

TortoiseSVN http://tortoisesvn.net/downloads http://tortoisesvn.tigris.org/

Svn1ClickSetup http://svn1clicksetup.tigris.org/

Subclipse http://subclipse.tigris.org/

Subversion中文站 http://www.subversion.org.cn/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章