【发布时间】:2014-06-24 00:14:18
【问题描述】:
我正在使用 SuperCSV 来解析 CSV 文件。我遇到的问题是我还有 3 个其他课程 - 办公室、车辆和汽车。
我制作了 Office The Grasp Creator,因此它可以创建 Vehicle 类型的对象,并且 Vehicle 扩展 Car。
名为 ImportCSV 的类实现了 SuperCSV 库。 ImportCSV 需要访问 OFFICE、Vehicle 和 Car 中的所有方法来解析 CSV 文件,否则我会收到错误 - SuperCsvReflectionException。
我怎样才能让 3 个不同类的所有方法访问 Class ImportCSV,或者对如何进行此操作有任何建议?
【问题讨论】:
-
你能发布那个异常的堆栈跟踪吗?和一些示例代码。否则很难理解这个问题。
-
这是输出:
Exception in thread "main" org.supercsv.exception.SuperCsvReflectionException: unable to find method setTYCODE(java.lang.String) in class portal.Office - check that the corresponding nameMapping element matches the field name in the bean, and the cell processor returns a type compatible with the field我尝试运行的方法是:while( (tenantRecord = beanReader.read(Office.class, header, processors)) != null )tenantRecord 是 Office 类型