嗨大家我在使用jGit库连接到提供的ssh服务器时遇到问题。我当前遇到的问题是"引起:org.eclipse.jgit.api.errors.JGitInternalException:目标路径"测试"已存在且不是空目录"请记住,我已查看http://www.codeaffine.com/2014/12/09/jgit-authentication/和其他stackoverflow帖子,他们的答案没有解决我的问题。是否有人可以协助我做错了什么?
try
{
String user = "username";
String host = "ssh://"+user+"@the.server.address/";
String password = "password";
SshSessionFactory sshSessionFactory = new JschConfigSessionFactory()
{
@Override
protected void configure(Host hc, Session session)
{
session.setPassword(password);
}
};
CloneCommand cloneCommand = Git.cloneRepository();
cloneCommand.setURI(host);
cloneCommand.setTransportConfigCallback(new TransportConfigCallback()
{
@Override
public void configure(Transport transport)
{
SshTransport sshTransport = (SshTransport) transport;
sshTransport.setSshSessionFactory(sshSessionFactory);
}
});
cloneCommand.call();
}
catch (Exception e)
{
System.out.println(e.getMessage());
System.out.println("Exception: " + e);
}
我得到的错误:
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Destination path "THE LOCAL DIR PATH" already exists and is not an empty directory at
org.eclipse.jgit.api.CloneCommand.verifyDirectories(CloneCommand.java:243)at
org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:179) at
assignment.MainFXMLDocumentController.buttonWidgetViewAction(MainFXMLDocumentController.java:136) ... 58 more