单纯记录。
利用svn进行版本控制,有两种方法,一种是利用tortoiseSVN和VisualSvn配合,一种是利用myeclipse里的svn插件和VisualSvn配合使用。
安装VisualSvn的方法是共有的。
一、安装VisualSvn
下载地址: https://www.visualsvn.com/server/download/
我现在最新的版本是VisualSVN-Server-3.0.1-x64.msi
默认安装即可。其中安装时有location安装路径和repositeries数据存放位置,注意选择。端口port要选择未被占用端口,由于本人已安装tomcat,所以我用80端口。
二、配置服务器端
点击开始->所有程序->VisualSVN ->VisualSVN Server Manager启动管理器
右键点击Repositories,Create new repositoriey,输入Name。比如signalVis。
右键点击User,Create User,设置User name,password
回到刚刚建立的testSvn,右键选择properties。设置用户权限。见下图。
服务器端已设置完毕。
下面先介绍安装tortoiseSVN方式。若采用MyEclipse svn插件,这步可以直接跳过。
三(1)、安装tortoiseSVN
下载地址:http://tortoisesvn.net/downloads.html
默认安装即可。
四(1)、使用
新建文件夹,打开文件夹,右键选择check out,弹出的URL输入,http://服务器端IP:80/svn/signalVis
在文件夹中新建文件,然后右键,选择提交,则文件就可以传到服务器。
下面介绍MyEclipse svn插件的使用
三(2)、本人安装MyEclipse9.0下安装,测试8.5也可以使用。
下载svn地址: http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=2240
版本 site-1.8.22.zip
新建文件夹,我建立在MyEclipse的安装目录下了,比如在这个目录下D:\Program Files\MyEclipse Blue Edition\MyEclipse Blue Edition 9
建立myplugins/svn
并在这个目录下D:\Program Files\MyEclipse Blue Edition\MyEclipse Blue Edition 9\myplugins\svn将下载的svn压缩文件夹里的features plugins这两个文件复制到此目录下。
然后执行此下面这个代码。
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* MyEclipse9 插件配置代码生成器
*
*
*/
public class PluginConfigCreator
{
public PluginConfigCreator()
{
}
public void print(String path)
{
List<String> list = getFileList(path);
if (list == null)
{
return;
}
int length = list.size();
for (int i = 0; i < length; i++)
{
String result = "";
String thePath = getFormatPath(getString(list.get(i)));
File file = new File(thePath);
if (file.isDirectory())
{
String fileName = file.getName();
if (fileName.indexOf("_") < 0)
{
print(thePath);
continue;
}
String[] filenames = fileName.split("_");
String filename1 = filenames[0];
String filename2 = filenames[1];
result = filename1 + "," + filename2 + ",file:/" + path + "/"
+ fileName + "//,4,false";
System.out.println(result);
} else if (file.isFile())
{
String fileName = file.getName();
if (fileName.indexOf("_") < 0)
{
continue;
}
int last = fileName.lastIndexOf("_");// 最后一个下划线的位置
String filename1 = fileName.substring(0, last);
String filename2 = fileName.substring(last + 1, fileName
.length() - 4);
result = filename1 + "," + filename2 + ",file:/" + path + "/"
+ fileName + ",4,false";
System.out.println(result);
}
}
}
public List<String> getFileList(String path)
{
path = getFormatPath(path);
path = path + "/";
File filePath = new File(path);
if (!filePath.isDirectory())
{
return null;
}
String[] filelist = filePath.list();
List<String> filelistFilter = new ArrayList<String>();
for (int i = 0; i < filelist.length; i++)
{
String tempfilename = getFormatPath(path + filelist[i]);
filelistFilter.add(tempfilename);
}
return filelistFilter;
}
public String getString(Object object)
{
if (object == null)
{
return "";
}
return String.valueOf(object);
}
public String getFormatPath(String path)
{
path = path.replaceAll("", "/");
path = path.replaceAll("//", "/");
return path;
}
public static void main(String[] args)
{
/*你的插件的安装目录*/
String plugin = "插件目录";
new PluginConfigCreator().print(plugin);
}
}
方法:在MyEclipse里新建java项目,新建类,命名为:
PluginConfigCreator,比如我的改为"D:/Program Files/MyEclipse Blue Edition/MyEclipse Blue Edition 9/myplugins/svn"
执行之后,打开MyEclipse安装目录,我的为D:\Program Files\MyEclipse Blue Edition\MyEclipse Blue Edition 9\configuration\org.eclipse.equinox.simpleconfigurator
打开bundles.info这个文件
将上面代码执行结果复制粘贴至此文件。
重启MyEclipse,svn已安装成功。
四(2)、使用
1、分两种,一种上传
项目首先要由,比如组长上传一个项目
MyEclipse里在想要上传到服务器的项目右键team->share project->SVN
创建新的资源库位置,输入URL:http://服务器端IP:80/svn/signalVis
上传完毕
2、组员导入项目
File->import ->SVN->从SVN检出项目
URL:http://服务器端IP:80/svn/signalVis
成功。