1

我试图使用 BeanIO 将 CSV 转换为 POJO,并发现了一个可能对你们中的一些人有所帮助的问题。

这是我得到的错误“无效字段'LastName',记录'user',流'userTemplate':类'com.mycompany.beanio.User'中没有这样的属性'LastName'”

<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="userTemplate" format="csv">

    <record  name="user" class="com.mycompany.beanio.User">    
        <field name="FirstName"/>
        <field name="LastName"/>
        <field name="Email" />
    </record>
</stream>
</beanio>

这是我的java类

package com.mycompany.beanio;
import org.apache.commons.lang3.RandomStringUtils;
import java.math.BigDecimal;


/**
*
* @author Yoash izhack yoashos@gmail.com   
*/
class User 
{


private String      FirstName;
private String      LastName;
private String      Email;
Get&Set dwon here

如您所见,我的班级确实有该财产,但我有一个例外。我对其进行了探索,发现从 java 类编写的属性对于第一个字符来说是未使用的。这意味着尽管我写了 LastName 两次,但 lastName 与 LastName 之间存在比较。已为此错误提交了修复程序。

4

1 回答 1

0

to start property names with an uncapitilized letter ist Java standard. So if you change your properties to the standard all will be work perfect.

于 2014-10-26T10:00:11.297 回答