2014-09-13 4 views
1

git 저장소를 로컬 디렉토리에 복제하는 프로젝트를 진행 중입니다. JGit을 사용하여 로컬 디렉토리에 저장소 복제하기

나는 the tutorial을 읽어 내 코드는 다음과 같습니다

/* 
* Clones a github project to the designated directory and checks it out. (Both prefix and postfix) 
* <p> 
* @param buildPath - String, the path where the directories will be created and the projects built. 
* @param bugID - String, the bug's id. 
* @param projectURL - String, the github URL used to clone the project. 
*/ 
public void DownloadAndSetup(String buildPath, String bugID, String projectURL, String prefixHash, String postfixHash) throws InvalidRemoteException, TransportException, GitAPIException { 
    String generalPath = buildPath+File.separator+bugID; 
    String prefixPath = generalPath+File.separator+"prefix"; 
    String postfixPath = generalPath+File.separator+"postfix"; 
    // Cloning & checking out to prefix 
    Git gitPrefix = Git.cloneRepository().setURI(projectURL).setDirectory(new File(prefixPath)).call(); 
    gitPrefix.checkout().setCreateBranch(true).setName("new-branch").setStartPoint(prefixHash).call(); 
    // Cloning & checking out to postfix 
    Git gitPostfix = Git.cloneRepository().setURI(projectURL).setDirectory(new File(postfixPath)).call(); 
    gitPostfix.checkout().setCreateBranch(true).setName("new-branch").setStartPoint(postfixHash).call(); 
} 

을하지만 실행하면

다음과 같은 오류
public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException { 
    GitDownloader gd = new GitDownloader(); 
    String buildPath = "C:\\Users\\dario_000\\Dropbox\\SheffInternship\\wsp\\AutoEv\\src\\tests"; 
    gd.DownloadAndSetup(buildPath, "download", "https://github.com/jhy/jsoup.git", "1e9ae842ca94f326215358917c620ac407323c81", "04e256ce9571e4239403b657126ce8eb30ad6776"); 
} 

내가 얻을 :

Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jsch/JSchException 
    at org.eclipse.jgit.transport.Transport.<clinit>(Transport.java:114) 
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:120) 
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178) 
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125) 
    at autoEvoSuite.GitDownloader.DownloadAndSetup(GitDownloader.java:26) 
    at tests.GITProjectDownloader.main(GITProjectDownloader.java:19) 
Caused by: java.lang.ClassNotFoundException: com.jcraft.jsch.JSchException 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    ... 6 more 

누구나 어떤있어 제안?

답변

0

JGit은 JSchJavaEWAH에 종속되어 있으며 JSch는 런타임 클래스 경로에 없습니다.

클래스 경로에 필요한 라이브러리를 수동으로 추가하거나 예를 들어 클래스 경로를 관리해야합니다. Maven 또는 OSGi (도구).