Jira+SVN整合开发整理

ConnectiontoSubversionrepositoryhttp://svn.xxx.cn/Currentfailed:org.tmatesoft.svn.core.SVNAuthenticationException:svn:Authenticationrequiredfor'<http://svn.xxx.cn:80>'

原因:据说是svnkit包的一个bug.

解决方案:

添加JVM系统参数-Dsvnkit.http.methods=Basic,Digest,NTLM

Propertiesproperties=System.getProperties();

properties.setProperty("svnkit.http.methods","Basic,Digest,NTLM");

org.tmatesoft.svn.core.SVNException:svn:UnabletocreateSVNRepositoryobjectfor

原因:svn访问地址与调用的方法不一致

解决方案:svn://xx.xx.xx--SVNRepositoryFactoryImpl.setup();

http://xx.xx.xx--DAVRepositoryFactory.setup();

mvninstall:install-file-Dfile=E:\software\svnkit.jar-DgroupId=thirdlib-DartifactId=svnkit-Dversion=1.3.5-Dpackaging=jar-DgeneratePom=true-DcreateChecksum=true

作用:将本地jar加入到maven2仓库。

maven1.0不含mvn命令,如需要将jar加入到本地的maven仓库,可以到仓库按其它包目录结构创建文件夹,并将本地jar拷贝到创建的目录下,在project.xml添加相应的依赖关系即可使用。

java.lang.IllegalArgumentException:Action'com.xxx.jira.web.action.issue.CheckSvnCommitIssue'couldnotbeinstantiated.Classisinvalidorstaticinitializershavefailedtorun

原因:未将相应的jar包拷贝到主程序的lib目录下,在插件部分加了jar包,所以编译不会出错,但当运行时就会报如上错误。

解决方案:在主程序的project.xm也需要加相应的依赖。

java访问svn测试代码:

public class History {

	public static void main(String[] args) {
		Properties properties = System.getProperties();
		properties.setProperty("svnkit.http.methods", "Basic,Digest,NTLM");
		DAVRepositoryFactory.setup();
		// SVNRepositoryFactoryImpl.setup();
		String url = "http://svn.xxx.cn/current";
		// String url = "svn://localhost";
		String name = "username";
		String password = "password";
		long startRevision = 0;
		long endRevision = -1; // HEAD (the latest) revision

		SVNRepository repository = null;

		try {
			repository = SVNRepositoryFactory.create(SVNURL
					.parseURIEncoded(url));
		} catch (SVNException e) {
			e.printStackTrace();
		}
		ISVNAuthenticationManager authManager = SVNWCUtil
				.createDefaultAuthenticationManager(name, password);
		repository.setAuthenticationManager(authManager);

		final Collection logEntries = new ArrayList();
		long start = System.currentTimeMillis();
		try {
			repository.log(new String[] { "" }, startRevision, endRevision,
					true, true, new ISVNLogEntryHandler() {
						public void handleLogEntry(SVNLogEntry entry) {
							if (entry.getMessage().indexOf("QS-5762") != -1) {
								logEntries.add(entry);
							}
						}
					});
		} catch (SVNException e) {
			e.printStackTrace();
		}

		for (Iterator entries = logEntries.iterator(); entries.hasNext();) {
			SVNLogEntry logEntry = (SVNLogEntry) entries.next();
			System.out.println("---------------------------------------------");
			System.out.println("revision: " + logEntry.getRevision());
			System.out.println("author: " + logEntry.getAuthor());
			System.out.println("date: " + logEntry.getDate());
			System.out.println("log message: " + logEntry.getMessage());

			if (logEntry.getChangedPaths().size() > 0) {
				System.out.println();
				System.out.println("changed paths:");
				Set changedPathsSet = logEntry.getChangedPaths().keySet();

				for (Iterator changedPaths = changedPathsSet.iterator(); changedPaths
						.hasNext();) {
					SVNLogEntryPath entryPath = (SVNLogEntryPath) logEntry
							.getChangedPaths().get(changedPaths.next());

					System.out.println(" "
							+ entryPath.getType()
							+ " "
							+ entryPath.getPath().substring(
									entryPath.getPath().lastIndexOf("/") + 1));
				}
			}
		}
	}
}

svn

相关推荐