Java Spring SFTP连接-从SFTP服务器获取文件

Java Spring SFTP连接-从SFTP服务器获取文件,java,spring,spring-integration,sftp,Java,Spring,Spring Integration,Sftp,我是春天的新手。我正在使用spring从远程服务器获取文件 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integratio

我是春天的新手。我正在使用spring从远程服务器获取文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:sftp="http://www.springframework.org/schema/integration/sftp"
xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/integration
    http://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/integration/sftp
    http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.2.xsd">

<bean id="sftpSessionFactory"
    class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <property name="host" value="xxxxxxxx" />
    <property name="user" value="wildfly" />
    <property name="password" value="w!ldfly" />
    <property name="port" value="22" />
</bean>

<int:channel id="sftpChannel" />

<sftp:inbound-channel-adapter id="triggerFtpInBound" auto-create-local-directory="true"
    local-directory="/tmp/test" filename-pattern="*" channel="sftpChannel"
    session-factory="sftpSessionFactory" remote-directory="/home/wildfly" delete-remote-files="true">
    <int:poller cron="1/10 * * * * *" max-messages-per-poll="1" />
</sftp:inbound-channel-adapter>

我没有得到任何错误,当我运行它,但我也没有得到任何文件复制。请告诉我代码中的错误。提前感谢。

仅查看静态配置很难进行调试

第一步是为
org.springframework.integration
打开调试日志记录,并查看发生了什么

如果你不能从日志中找到答案,就把它们贴出来;如果此处太大,请使用github gist、pastebin或类似工具

Spring Integration在封面下使用jsch;您可以按说明启用其日志记录。

添加“KnownHosts”属性解决了我的问题。我现在正在传送文件

<property name="knownHosts" value = "C:\knownhosts"/>

<property name="knownHosts" value = "C:\knownhosts"/>