0
  1. 创建了 Jaxb2Marshaller 对象。
  2. 需要将 java POJO 转换为 XML(编组)。

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

代码流程:-

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

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

4

1 回答 1

0

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

.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

于 2018-08-09T22:50:31.743 回答