天天看點

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.

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

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.

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

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.

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

Step 4:

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

Eclipse中SVN版本控制插件的安裝和使用
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.

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

Step 6:

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

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

Step 7:

Click the button to accept the license agreement.

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

Step 8:

Confirm the install location

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

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.

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

Step 10:

Just a screenshot of the in-process installation.

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

Step 11:

Eclipse needs to be restarted after installing Subclipse.

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

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.

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

OK

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

解除安裝的方法也很簡單,也是點選 Help => Software Updates => Manage Configuration

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

按上圖操作就可以解除安裝了。

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

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

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

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

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

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

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

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

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

順便說一下剛才為什麼要删除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/

繼續閱讀