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

查看:20
本文介绍了我可以在一个包中有多个绑定注释的类,并且仍然可以在 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 开始,情况不再如此,因为您可以安全地在同一个包中拥有多个模型,因为您现在使用类名而不是包名配置 bindy."

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天全站免登陆