与FTP服务器连接,但没有在Spring Integration中下载文件,任何人都可以解决此问题



这是我的主要类

public class FtpInboundChannelAdapterSample {
private static final Logger LOGGER = LoggerFactory.getLogger(FtpInboundChannelAdapterSample.class);
public static void main(String[] args) throws Exception {
    FtpInboundChannelAdapterSample ftp=new FtpInboundChannelAdapterSample();
    ftp.ftpDownload();

}
public void ftpDownload() throws Exception {
    ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(
            "META-INF/spring/integration/FtpInboundChannelAdapterSample-context.xml");
    PollableChannel ftpChannel = ctx.getBean("ftpChannel", PollableChannel.class);

    System.out.println("Files are transferred ");
    ctx.close();
}

}

和我的.xml如下

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="${host}"/>
    <property name="port" value="${availableServerPort}"/>
    <property name="username" value="${userid}"/>
    <property name="password" value="${password}"/>
</bean>
<int-ftp:inbound-channel-adapter id="ftpInbound"
            channel="ftpChannel"
            session-factory="ftpClientFactory"
            filename-pattern="*.*"
            auto-create-local-directory="true"
            delete-remote-files="false"
            remote-directory="ftp://portal.********.com/foldername/"
            local-directory="${localDir}">
        <int:poller fixed-rate="1000"/>
</int-ftp:inbound-channel-adapter>

<int:channel id="ftpChannel">
    <int:queue/>
</int:channel>

这是给出远程目录路径的一种方法吗?

remote-directory =" ftp://portal.devellal.devel.deblal.ghydevey.com/foldername/"

远程directory ="/ftpsample/"

我尝试了两者,但没有从服务器下载

如果我将Localhost与Filezilla服务器一起下载。

正确的语法为 remote-directory="/ftpSample/"-您不需要URL,因为该连接是由会话工厂指定的。

您确定需要领先的/吗,应该是remote-directory="ftpSample/"吗?

打开调试日志记录并检查服务器日志。

尝试一下:
remote-directory="ftps://portal.********.com/foldername/"
remote-directory="sftp://portal.********.com/foldername/"

最新更新