Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何定义多个sftp连接?_Spring_Spring Integration - Fatal编程技术网

Spring 如何定义多个sftp连接?

Spring 如何定义多个sftp连接?,spring,spring-integration,Spring,Spring Integration,我试图使用出站网关从多个sftp服务器下载文件,sftp服务器的数量在属性中配置(这意味着我需要动态定义连接), my application.properties: sftp.host=host1,host2 sftp.user=user1,user2 sftp.pwd=pwd1,pwd2 当前,我将java配置用作: @Configuration 公共类SFtpConfig{ static Logger logger = LoggerFactory.getLogger(SFtpConf

我试图使用出站网关从多个sftp服务器下载文件,sftp服务器的数量在属性中配置(这意味着我需要动态定义连接), my application.properties:

sftp.host=host1,host2
sftp.user=user1,user2
sftp.pwd=pwd1,pwd2
当前,我将java配置用作:

@Configuration
公共类SFtpConfig{

static  Logger logger = LoggerFactory.getLogger(SFtpConfig.class);

@Autowired
SftpServerProperties sftpServerProperties;

@Autowired
SftpClientProperties sftpClientProperties;

@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {

 ...
}

@Bean(name = "myGateway")
@ServiceActivator(inputChannel = "sftpChannel")
public MessageHandler handlerLs() {

 ...
}

@MessagingGateway
public interface DownloadGateway {
    @Gateway(requestChannel = "sftpChannel")
    List<File> start(String dir);
}

@Bean(name="sftpChannel")
public MessageChannel sftpChannel() {
    return new DirectChannel();
}

}
staticlogger-Logger=LoggerFactory.getLogger(SFtpConfig.class);
@自动连线
SftpServerProperties SftpServerProperties;
@自动连线
SFTPlientProperties SFTPlientProperties;
@豆子
公共会话工厂sftpSessionFactory(){
...
}
@Bean(name=“myGateway”)
@ServiceActivator(inputChannel=“sftpChannel”)
公共消息处理程序handlerLs(){
...
}
@消息网关
公共接口下载网关{
@网关(requestChannel=“sftpChannel”)
列表开始(字符串目录);
}
@Bean(name=“sftpChannel”)
公共消息频道sftpChannel(){
返回新的DirectChannel();
}
}
但是此配置仅用于连接到一个sftp服务器,因此如何使用application.properties配置定义多个sftp连接?
我的意思是SeaStudio/Huffer-/Gate/Channe的动态数(一些bean有注释,如何动态定义这样的bean?)< /P> < P>您应该考虑用相同的内容声明不同的属性,但代码< >连接工厂< /C> >:< /P>
/**
 * Set the parent of this application context.
 * <p>Note that the parent shouldn't be changed: It should only be set outside
 * a constructor if it isn't available when an object of this class is created,
 * for example in case of WebApplicationContext setup.
 * @param parent the parent context
 * @see org.springframework.web.context.ConfigurableWebApplicationContext
 */
void setParent(@Nullable ApplicationContext parent);
/**
*设置此应用程序上下文的父级。
*请注意,不应更改父级:它只应设置在外部
*如果在创建此类的对象时构造函数不可用,
*例如,在WebApplicationContext设置的情况下。
*@param parent父上下文
*@请参阅org.springframework.web.context.ConfigurableWebApplicationContext
*/
void setParent(@Nullable ApplicationContext parent);

< /代码> 您应该考虑用相同的内容声明不同的属性,但对于代码< >连接工厂> /代码>:

/**
 * Set the parent of this application context.
 * <p>Note that the parent shouldn't be changed: It should only be set outside
 * a constructor if it isn't available when an object of this class is created,
 * for example in case of WebApplicationContext setup.
 * @param parent the parent context
 * @see org.springframework.web.context.ConfigurableWebApplicationContext
 */
void setParent(@Nullable ApplicationContext parent);
/**
*设置此应用程序上下文的父级。
*请注意,不应更改父级:它只应设置在外部
*如果在创建此类的对象时构造函数不可用,
*例如,在WebApplicationContext设置的情况下。
*@param parent父上下文
*@请参阅org.springframework.web.context.ConfigurableWebApplicationContext
*/
void setParent(@Nullable ApplicationContext parent);

Hi@Artem,你能给我更多提示吗?sftp服务器的数量由属性文件决定,我尝试了BeanDefinitionRegistryPostProcessor,但没有成功。您好@Artem,您能提供更多提示吗?sftp服务器的数量由属性文件决定,我尝试了BeanDefinitionRegistryPostProcessor,但没有成功。