【问题标题】:Spring-integration convert xml configuration into java configSpring-integration 将 xml 配置转换为 java 配置
【发布时间】:2017-07-17 14:31:22
【问题描述】:

我想将我的 xml 配置转换为 Java 类配置,但我找不到解决方案。例如我的一段配置:

<file:inbound-channel-adapter id="filesIn" directory="file:${java.io.tmpdir}/spring-integration-samples/input"
                              filename-regex="^.*\.(xml|json)$" >
    <int:poller id="poller" fixed-delay="5000"/>
</file:inbound-channel-adapter>


<int:service-activator input-channel="filesIn"
                       output-channel="filesOut"
                       ref="handler"/>

<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"
                               delete-source-files="true"/>



<file:inbound-channel-adapter id="filesContent" directory="file:${java.io.tmpdir}/spring-integration-samples/output"
                              filename-regex="^.*\.(xml|json)$" prevent-duplicates="true">
    <int:poller id="poller2" fixed-delay="5000"/>
 </file:inbound-channel-adapter>

如何在本地机器上使用 sftp(src 目录)以及如何在 java 类中编写此配置来制作相同的东西。给我任何建议,我正在寻找答案,但我找不到出路。

【问题讨论】:

    标签: spring-integration spring-integration-sftp


    【解决方案1】:

    首先你应该从Spring Integration Java DSL Reference Manual开始。在那里,您将找到 Java DSL 的一般概念以及它与 XML 配置的关系。

    您可以在相应的参考手册Chapter 中找到 SFTP 入站/出站通道适配器配置示例。例如,Java DSL 中的 &lt;int:service-activator&gt; 可能看起来像:

    .handle(handler)
    

    如果您在单个 IntegrationFLow 中声明所有内容,则没有频道定义。

    【讨论】:

    • 好的,但我想使用注释来实现。你能给我任何建议如何使用注释来做同样的事情吗?因为我找不到替换出站通道适配器的方法。 @ArtemBilan
    • 出站通道适配器是@ServiceActivator。查看相同的 SFTP 章节:docs.spring.io/spring-integration/reference/html/…
    猜你喜欢
    • 2015-12-12
    • 2015-05-30
    • 2011-01-15
    • 2020-12-19
    • 1970-01-01
    • 2015-07-22
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    相关资源
    最近更新 更多