spring-integration - 如何在配置为xml配置的spring-integration项目中使用@RefreshScrop
问题描述
我正在使用 spring 集成将 ftp 文件传输到远程服务器,并且我正在使用基于 xml 的配置。我想使用 spring cloud config ,所以我可以将所有属性文件移动到 git 并使用 @RefreshScope 刷新属性。在只有 xml 的 spring 集成中实现这一目标的最佳方法是什么。
我有以下代码:
<bean id="inDefaultSftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="${sftp.host}" />
<property name="port" value="${sftp.port}" />
<property name="user"
value="${sftp.username}" />
<property name="password"
value="${sftp.password}" />
<property name="allowUnknownKeys" value="true" />
</bean>
解决方案
尝试scope="refresh"
并<aop:scoped-proxy/>
为该 bean 定义。像这样的东西:
<bean id="inDefaultSftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"
scope="refresh">
<property name="host" value="${sftp.host}" />
<property name="port" value="${sftp.port}" />
<property name="user" value="${sftp.username}" />
<property name="password" value="${sftp.password}" />
<property name="allowUnknownKeys" value="true" />
<aop:scoped-proxy/>
</bean>
推荐阅读
- amazon-web-services - AWS API Gateway - 您可以混合私有访问和公共身份验证访问吗?
- nginx - 删除网址末尾的所有斜杠
- arrays - 如何使用 Go 更新 MongoDB 中嵌入式数组的最后一项?
- python - Pandas:根据另一个数据框的长度添加列信息
- java - Spring,如何对字符串进行编码和解码
- wordpress - wordpress 重写规则和 mod_tile (renderd) 在同一个域上
- python - Python - 如何从在线存储库下载具有给定名称的文件(给定其 URL)
- python - pandas 一行 DF 到字典,包括索引值作为键
- google-analytics - 将页面 URL 添加到报告
- java - 如何创建 Spring RepositoryRestResource 的合约测试