【问题标题】:How to integrate the Jaxb2Marshaller in the Spring integration route?如何在 Spring 集成路由中集成 Jaxb2Marshaller?
【发布时间】:2018-08-09 22:12:31
【问题描述】:
  1. 创建了 Jaxb2Marshaller 对象。
  2. 需要将 java POJO 转换为 XML(编组)。

在集成路径中集成 Jaxb2Marshaller 时需要帮助。

代码流程:-

@Bean
    public IntegrationFlow flow() throws JAXBException {
        return from(...).
                .enrichHeaders(...)
                .handle(...)
                .transform(processor()::generateXml)
                .channel(...)
                               .get();
    }

如何在 transform() 步骤中添加 Jaxb2Marshaller?

【问题讨论】:

    标签: spring spring-integration spring-oxm


    【解决方案1】:

    有一个开箱即用的变压器可供使用:

    .transform(new MarshallingTransformer(jaxbMarshaller()))
    

    https://docs.spring.io/spring-integration/docs/current/reference/html/xml.html#xml-marshalling-transformer

    如何创建Jaxb2Marshaller可以参考Spring Framework文档:

    https://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#oxm-jaxb2

    【讨论】:

    • 我在 spring-integration-core-5.0.5.RELEASE.jar 中没有看到那个转换器,它被删除了吗?
    • spring-integration-xml 模块的一部分。因此,您需要在项目中添加该依赖项
    • 有人可以帮我解决 Jaxb 元帅问题吗? stackoverflow.com/questions/68031311/…
    猜你喜欢
    • 2015-02-06
    • 2015-06-30
    • 2018-06-15
    • 2021-11-23
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多