Apache骆驼:绑定非法参数异常 [英] Apache camel:bindy illegal argument exception
本文介绍了Apache骆驼:绑定非法参数异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 POJO 和 CSV 之间进行数据格式转换,反之亦然.在将 CSV 转换为对象文件(解组)时,我收到了 int 数据类型的非法参数异常.仅用于字符串其工作正常.下面是我的POJO
I am doing data format conversion between POJO to CSV and vice versa. In this while converting CSV to Object file(Unmarshalling) i am getting illegal argument exception for int data type. Only for string its working fine. Below is my POJO
@CsvRecord(separator="//|",crlf="UNIX",generateHeaderColumns=false)
public class EmployeeVO implements Serializable{
private static final long serialVersionUID = -663135747565879908L;
@DataField(pos=1)
private String name;
@DataField(pos=3)
private Integer age;
@DataField(pos=2)
private String grade;
// getter setter
}
csv 数据
sumit|4th standrad|22
上面的csv是从上面的POJO生成的.但是在将 CSV 转换为 POJO 时,我遇到了以下异常
the above csv is generated from the above POJO. But at the time of converting CSV to POJO i am getting folloing exception
java.lang.IllegalArgumentException: Parsing error detected for field defined at the position: 3, line: 1
以下是我的骆驼 - 上下文文件供您参考
following are my camel - context file for your reference
元帅
<route>
<from uri="cxf:bean:rtoemplyeeService"/>
<convertBodyTo type="java.lang.String" id="stringInput"/>
<bean ref="govtEmpBean" method="getEmployeeCSV" beanType="govtEmpBean" id="govtEmp"/>
<log message="before marshalling ================== ${body}"/>
<marshal ref="bindyDataformat">
<bindy type="Csv" packages="com.mycompany.converter.vo"/>
</marshal>
<log message="after marshalling ================== ${body}"/>
<to uri="file://D:/JATO_WORK/repo_bkp/csv/"/>
<setBody>
<simple>CSV output is generated at file system </simple>
</setBody>
</route>
取消元帅
<route id="csvtoobject">
<from uri="file://D:/JATO_WORK/repo_bkp/csv?delay=10000&initialDelay=10"/>
<log message="csv string ============= ${body}"/>
<unmarshal ref="bindyDataformat"/>
<log message="${body}"/>
<bean ref="govtEmpBean" method="printCSVObject" beanType="govtEmpBean" id="govtEmp"/>
</route>
推荐答案
需要指定csv记录如下
You need to specify the csv record as follows
@CsvRecord(separator = "\\|")
这篇关于Apache骆驼:绑定非法参数异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文