2017-09-25 170 views
0

在这里,我试图从谷歌驱动器 下载(复制)一个文件,但我得到的错误是我还不明白。 我不确定源路由 from().to(localDrive)的正确说法。如何通过apache骆驼从谷歌驱动器下载文件,我得到AbstractApiComponent无法访问?

public class GdriveCopyFile { 
    public static void main(String ar[])throws Exception{ 

    ArrayList<String> scope = new ArrayList<String>(); 
    scope.add("https://www.googleapis.com/auth/drive.file"); 

    CamelContext context=new DefaultCamelContext(); 
    GoogleDriveConfiguration configuration=new GoogleDriveConfiguration(); 

    configuration.setApplicationName("GdriveCopyFile"); 
    configuration.setClientId(".."); 
    configuration.setClientSecret(".."); 
    configuration.setScopes(scope); 

    configuration.setAccessToken("..); 
    configuration.setRefreshToken(".."); 

     GoogleDriveComponent gDriveCompo=new GoogleDriveComponent(); 
     gDriveCompo.setConfiguration(configuration);  //32 
     context.addComponent("google-drive", gDriveCompo); //33 

     context.addRoutes(new RouteBuilder(){ 
     @Override 
     public void configure()throws Exception{ 

     from("google-drive://drive-files/copy?..").to("file:.."); 

    } 
     }); 
    context.start(); 
    Thread.sleep(10000); 
    context.stop(); 
    }} 

错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Google-Drive: Compilation
failure: Compilation failure: /home/rajat/workspace/Google-Drive/src/main/java/com/pkgName/gdrive /Google_Drive/GdriveCopyFile.java:[32,16] error: cannot access AbstractApiComponent class file for org.apache.camel.util.component.AbstractApiComponent not found/home/rajat/workspace/Google-Drive/src/main/java/com/pkgName/gdrive/Google_Drive/GdriveCopyFile.java:[33,42] error: incompatible types: GoogleDriveComponent cannot be converted to Component

而且我卡在这里有什么错我的代码?

+0

也许你有一个混合版本的骆驼或一些缺少JAR的类路径问题。 –

+0

非常感谢。我在做这个工作。 –

回答

0

看起来你没有AbstractApiComponent这是GoogleDriveComponent的父类。现在org.apache.camel.util.component.AbstractApiComponent是骆驼核心的一部分,所以更好地看看你使用的是什么版本的骆驼。

+0

是的,它闻起来像在那里配置了错误的JARs的类路径问题。 –

+0

感谢您考虑骆驼核心的一些变化我现在更改版本的版本是2.19.3,现在我得到一些努力后:无法创建路由路由1:路由(路由1)[[从[谷歌驱动器://驱动器-files/copy?fileId = 0 ...因为缺少drive-files/copy属性,需要[content]中的一个或多个,这是我的路由from(“google-drive:// drive-files/copy ?fileId = 0BxLLYotaad42NmpJRTJNQVpZVDQ“)'我尝试了我所知道的。在这里我需要帮助。我对此表示赞赏。 –

+1

首先,如果您尝试下载文件,则复制将不会执行。阅读谷歌驱动器API文档,EOD骆驼只是核心API函数的一个层。 'copy'创建一个文件的副本,不会下载它。我没有使用谷歌驱动器组件,但根据文档它不提供'出口'端点。也许@克劳斯·易卜生可以更好地评论。 – Gautam

相关问题