Spring 集成中的 Marshaller

发布于 2025-01-12 09:36:59 字数 585 浏览 3 评论 0原文

我正在尝试在 spring 集成中将 java 对象编组为 xml。我尝试使用新的 MarshallingTransformer。但我不知道如何将编组器传递给它。 这是我的代码:

return IntegrationFlows.from(Http.inboundGateway("/foo")
                            .requestMapping(m -> m.methods(HttpMethod.POST)
                                   
                            )
                    )
                
                    .transform(xmlToObjectTransformer)
                    .convert(Customer.class)
                    .transform(new MarshallingTransformer("the marshaller should come here"))

                    .get();

I am trying to marshal java objects to xml in spring integration. i've tried to use new MarshallingTransformer. but i don't know how to pass the marshaller into it.
This is my code:

return IntegrationFlows.from(Http.inboundGateway("/foo")
                            .requestMapping(m -> m.methods(HttpMethod.POST)
                                   
                            )
                    )
                
                    .transform(xmlToObjectTransformer)
                    .convert(Customer.class)
                    .transform(new MarshallingTransformer("the marshaller should come here"))

                    .get();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别忘他 2025-01-19 09:36:59

问题不清楚。
您可能需要了解这些编组器是什么以及如何配置它们: https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html#oxm

然后,您只需要为相应的 Marshaller 提供一个 bean,并将其注入到该 MarshallingTransformer ctor 中。

The question is not clear.
You probably need to learn what are those marshallers and how to configure them: https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html#oxm.

Then you just need to have a bean for respective Marshaller and inject it into that MarshallingTransformer ctor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文