我最近开始使用Spring Integration,我遇到了将文件上传到我的ftp服务器的问题。当我尝试使用该命令发送文件时,不发生任何事情,并且程序执行被停止。 能帮到我吗? Tks很多!
以下是来源:
FtpOutbound-context.xml中
<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="xxxx"/>
<property name="port" value="xxx"/>
<property name="username" value="xxxxx"/>
<property name="password" value="xxxxx"/>
</bean>
<int-ftp:outbound-channel-adapter
session-factory="ftpClientFactory"
channel="ftpChannel"
remote-directory="/xxxx/xx/"
remote-filename-generator-expression="headers[fileName]">
</int-ftp:outbound-channel-adapter>
<int:channel id="ftpChannel"/>
UploadServiceApplication.java
public void run(ApplicationArguments args) throws Exception {
ConfigurableApplicationContext ctx =
new ClassPathXmlApplicationContext("META-INF/spring/integration/FtpOutbound-context.xml");
MessageChannel ftpChannel = ctx.getBean("ftpChannel", MessageChannel.class);
File file = new File("C:/Desenvolvimento/teste.txt");
final Message<File> messageFile = MessageBuilder.withPayload(file).setHeader("fileName", file.getName()).build();
ftpChannel.send(messageFile);
Thread.sleep(2000);
}