阿帕奇骆驼SFTP下载不起作用

问题描述:

我想从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

文件从服务器成功下载,但位置是没有文件就无法下载不同的左右。

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

它正在用户主目录内创建上传目录,这是它在预期目录中不可用的原因。