2017-09-25 169 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

相關問題