CsvDozerBeanWriter
Bean インスタンスを CSV ファイルに書き込むために使用しています。Bean を CSV に書き込む前に使用したコード例に従います。Bean の属性が ( ではなく) 空CsvDozerBeanWriter#configureBeanMapping(...)
の場合を除いて、すべてが正常に機能します。そのような属性は、書き込み前に Bean から中間インスタンスにコピーされないことがわかりました。これにより、列の数がセル プロセッサの数と一致しないため、例外が発生します。String
null
CsvDozerBeanData
configureBeanMapping(...)
掘り下げてみると、 Dozer を に設定するのと同じことを実行することがわかりましmap-empty-string
たFalse
。したがって、空の文字列はすべてマップされません (null
文字列は引き続きマップされます)。
どうすればこれを克服できますか?DozerBeanMapper
(ドキュメントにあるように)自分で提供するのが最善の方法ですか?
アップデート:
私が得た例外の詳細は次のとおりです。
org.supercsv.exception.SuperCsvException: The number of columns to be processed (7) must match the number of CellProcessors (12): check that the number of CellProcessors you have defined matches the expected number of columns being read/written
context={lineNo=2, rowNo=2, columnNo=1, rowSource=[a, b, c, d, e, f, g]}
org.supercsv.exception.SuperCsvException: The number of columns to be processed (7) must match the number of CellProcessors (12): check that the number of CellProcessors you have defined matches the expected number of columns being read/written
context={lineNo=2, rowNo=2, columnNo=1, rowSource=[a, b, c, d, e, f, g]}
at org.supercsv.util.Util.executeCellProcessors(Util.java:78)
at org.supercsv.io.dozer.CsvDozerBeanWriter.write(CsvDozerBeanWriter.java:133)
Bean には から までの属性String
があります。~の属性は空の文字列です。a
l
h
l
更新 2:
ここにテストケースがあります。