繁体   English   中英

使用Spring集成复制文件

[英]copy file using spring integration

您如何使用Spring Integration将文件从一个地方复制到另一个地方。 就我而言,我想将战争外部的文件复制到战争内部。 这是我正在考虑的代码片段:

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns:beans="http://www.springframework.org/schema/beans" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://www.springframework.org/schema/integration"
             xmlns:file="http://www.springframework.org/schema/integration/file"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                 http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
                                 http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd
                                 http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-1.0.xsd
             ">

<poller max-messages-per-poll="1" id="defaultPoller" default="true">
    <interval-trigger interval="1000"/>
</poller>


<file:inbound-channel-adapter id="filesIn"    
                              filename-pattern="ha-jdbc-cluster1.xml"
                              directory="file:/etc/****/" />


<file:outbound-channel-adapter id="filesOut" directory="classpath:/WEB-INF/classes" />

但可耻的是它不起作用。 有人知道怎么做吗?

提前致谢 .....

我认为该问题与目标目录有关。 您正在使用“ classpath:”前缀,该前缀不能用于向其中写入文件,而只能用于读取文件。

请通过复制此路径的文件让我们知道您要实现的目标,我们将尝试提出另一种方法来实现这一目标。

file:inbound-file-adapter上的目录应该是可以解析为单个目录(java.io.File实例)的目录。 不支持使用一个适配器读取多个目录,最后我检查了一下...

我会尝试将入站目录和出站目录更改为理智的/众所周知的,例如/ tmp中的两个目录-/ tmp / a和/ tmp / b。 如果这行得通,那么您就知道您的配置是合理的,只是目录的值很奇怪。 如果您使用Maven以及STS / Eclipse或IntelliJ,则很容易调出入站通道适配器实现类并进行调试(FileReadingMessageSource,IIRC)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM