2015-04-21 63 views
1

我正在使用Aether實用程序庫來管理依存關係。當我嘗試下載maven工件的傳遞依賴關係時,我得到一個以編程方式從遠程Maven回購下載工件

java.io.IOException: Invalid Content-Range header for partial download 

錯誤。我使用幾乎相同的代碼從以太例如這裏https://github.com/eclipse/aether-demo/blob/master/aether-demo-snippets/src/main/java/org/eclipse/aether/examples/ResolveTransitiveDependencies.java

/** 
    * Resolves the transitive (compile) dependencies of an artifact. 
    */ 

公共類ResolveTransitiveDependencies {

public static void main(String[] args) 
    throws Exception 
{ 
    System.out.println("------------------------------------------------------------"); 
    System.out.println(ResolveTransitiveDependencies.class.getSimpleName()); 

    RepositorySystem system = Booter.newRepositorySystem(); 

    RepositorySystemSession session = Booter.newRepositorySystemSession(system); 

    Artifact artifact = new DefaultArtifact("org.eclipse.aether:aether-impl:1.0.0.v20140518"); 

    DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE); 

    CollectRequest collectRequest = new CollectRequest(); 
    collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE)); 
    collectRequest.setRepositories(Booter.newRepositories(system, session)); 

    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter); 

    List<ArtifactResult> artifactResults = 
     system.resolveDependencies(session, dependencyRequest).getArtifactResults(); 

    for (ArtifactResult artifactResult : artifactResults) 
    { 
     System.out.println(artifactResult.getArtifact() + " resolved to " + artifactResult.getArtifact().getFile()); 
    } 
} 

}

回答

4

我通過刪除本地倉庫神器瓶解決了這個問題,但是我仍然不確定爲什麼會發生這種異常,這似乎發生在網絡不穩定時。希望它會有所幫助。

相關問題