【发布时间】:2013-08-06 19:16:12
【问题描述】:
我最近将我的 BeanIO 框架升级到 2.0.6 版本,以将我的平面(制表符分隔)文件解析为 java 对象,我注意到这种奇怪的行为。 我不能在最后一个文件行中将字段保留为空,因为 BeanIO 向我抛出此错误消息:“预计最少出现 1 次。”
我什至尝试将整个记录的 maxLength 设置为 4,以便它考虑最后的额外空字段,但它仍然会引发该异常。奇怪的是,它只对最后一行执行此操作,而对其他行中的空字段不执行。
映射:
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
<stream name="Inventory" format="delimited" strict="true" resourceBundle="com.crunchtime.mapping.cdp.Inventory">
<record name="myRecord" minOccurs="1" maxOccurs="unbounded" minLength="0" maxLength="4" class="com.test.Record">
<field name="userName" type="string"/>
<field name="userId" type="string"/>
<field name="type" type="string"/>
<field name="version" type="string"/>
</record>
</stream>
</beanio>
文件:
Mark User1 M 1.0
Tom User2 D 1.1
Jim User3 M 2.0
Scott User4 G
是否有人对如何禁用该行为有任何想法? 我查看了 beanio.properties,但我无法修改,因为它已被锁定。
【问题讨论】:
标签: java parsing text-parsing bean-io