我使用DSL API方式配置SftpOutboundGateway以发出自定义命令。在下面的示例中,我上传文件并随后远程移动:
public IntegrationFlow sftpOutboundFlow() {
return from(getFileToSftpChannel()).handle(Sftp.outboundGateway(getSftpSessionFactory(), PUT, "dir")).handle(Sftp.outboundGateway(getSftpSessionFactory(), MV, "dir")).channel(new NullChannel()).get();
但是,当我运行这个时,我得到:
Caused by: java.lang.IllegalArgumentException: 'remoteDirectoryExpression' is required
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:276)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:272)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.doPut(AbstractRemoteFileOutboundGateway.java:597)
原因是RemoteFileTemplate应该由Spring(InitializingBean,BeanFactoryAware)初始化,但它不是:
AbstractRemoteFileOutboundGateway
/**
* Construct an instance with the supplied session factory, a command ('ls', 'get'
* etc), and an expression to determine the filename.
* @param sessionFactory the session factory.
* @param command the command.
* @param expression the filename expression.
*/
public AbstractRemoteFileOutboundGateway(SessionFactory<F> sessionFactory, Command command, String expression) {
this(new RemoteFileTemplate<F>(sessionFactory), command, expression);
}
这是一个错误还是我错误地使用了这个?感谢。
答案 0 :(得分:0)
嗯,这不完全是个错误...
remoteDirectoryExpression
是RemoteFileTemplate
的一个选项,可以从Spring Integration Java DSL 1.1开始注入Sftp.outboundGateway()
。