2017-07-28 70 views
0

我想從SFTP服務器位置下載文件,但日誌看起來不錯,最後沒有任何東西從服務器下載到local.No錯誤也來了。請提前給你的投入感謝。阿帕奇駱駝SFTP下載不起作用

可用

SFTP文件:

[[email protected] test1]# ls /tmp/files/test1 
test1.txt test2.txt test3.txt test4.txt 

路由器:

@Component 
public class SampleCamelRouter extends RouteBuilder { 

    @Override 
    public void configure() throws Exception { 
     getContext().getShutdownStrategy().setTimeout(10); 

     from("sftp://[email protected]/tmp/files/test1?password=pass") 
       .to("file:C:/out") 
       .log("Downloaded file ${file:name} complete."); 
    } 

} 

登錄:

o.a.camel.spring.SpringCamelContext  : Route: route1 started and consuming from: sftp://[email protected]/tmp/files/test1/test1.txt?password=xxxxxx 
o.a.camel.spring.SpringCamelContext  : Total 1 routes, of which 1 are started. 
o.a.camel.spring.SpringCamelContext  : Apache Camel 2.18.1 (CamelContext: SampleCamel) started in 30.871 seconds 
s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http) 
c.camel.examples.SampleCamelApplication : Started SampleCamelApplication in 37.837 seconds (JVM running for 38.891) 

的pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>org.springframework</groupId> 
    <artifactId>gs-spring-boot</artifactId> 
    <version>0.1.0</version> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.5.5.RELEASE</version> 
    </parent> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-spring-boot-starter</artifactId> 
      <version>2.18.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-stream-starter</artifactId> 
      <version>2.18.1</version> 
     </dependency> 

     <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-ftp</artifactId> 
      <version>2.18.1</version> 
     </dependency> 

     <dependency> 
      <groupId>io.hawt</groupId> 
      <artifactId>hawtio-springboot</artifactId> 
      <version>2.0.0</version> 
     </dependency> 

    </dependencies> 


    <properties> 
     <java.version>1.8</java.version> 
    </properties> 


    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 

</project> 
+0

Windows版本?您是否嘗試使用其他文件'C:/測試/ out'? – Azeem

+0

感謝您的回覆,Windows7以及更改位置的行爲方式會有所不同? – sunleo

+0

是的。有時可能有權限問題。您是否檢查過您使用的路徑中是否有文件,即'C:\ out'?然後,嘗試其他路徑並再次測試。 – Azeem

回答

0

文件從服務器成功下載,但位置是沒有文件就無法下載不同的左右。

Location from download :[email protected]/tmp/uta/test1 
Location from downloaded:[email protected]/home/user/tmp/uta/test1 

它正在用戶主目錄內創建上傳目錄,這是它在預期目錄中不可用的原因。