我可以在一个包中有多个绑定注释类并且仍然在 Camel 中解组 CSV 吗? [英] Can I have multiple bindy annotated classes in a package and still unmarshal CSVs in Camel?

查看:8
本文介绍了我可以在一个包中有多个绑定注释类并且仍然在 Camel 中解组 CSV 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个像 my.company.bindy 这样的包,其中包含多个类,所有类都使用 Bindy 注释进行注释.然后我想要骆驼路线,可以将 CSV 解组为其中一种类型.我已经完成了所有工作,但是如果我在包中有多个绑定注释类,则解组失败.这是因为 Bindy 试图将 CSV 行解组到包中的每个类中.并且一条特定的行不会正确编组到多个类中.我的数据格式在 Spring 中声明如下:

I would like to have a package like my.company.bindy with several classes in it all annotated with Bindy annotations. Then I'd like to have Camel routes that can unmarshal CSV into one of these types. I've got it all working, but unmarshalling fails if I have more than one bindy annotated class in the package. This because Bindy is trying to unmarshal the CSV line into every class in the package. And a particular line won't properly marshal into more than one of the classes. My dataformat is declared in Spring like this:

<bean class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
    <property name="packages" value="my.company.bindy"/>
</bean>

推荐答案

Camel 2.16.0 已修复此问题.

This issue has been fixed with Camel 2.16.0.

来自 http://camel.apache.org/bindy.html

如果你使用多个模型,每个模型都必须放在自己的包中,以防止出现不可预知的结果.

"If you use multiple models, each model has to be placed in it's own package to prevent unpredictable results.

从 Camel 2.16 开始,情况不再如此,因为您可以安全地在同一个包中拥有多个模型,因为您现在使用类名而不是包名来配置绑定."

From Camel 2.16 onwards this is no longer the case, as you can safely have multiple models in the same package, as you configure bindy using class names instead of package names now."

这篇关于我可以在一个包中有多个绑定注释类并且仍然在 Camel 中解组 CSV 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆