我正在尝试处理两个.csv
文件并将其数据保存到数据库中。
我正在使用java dsl而不是spring。
更好地解释一下情景:
我正在读取两个.csv
文件并处理它们以在sql数据库中上传它们的数据。我为此执行的步骤是
EngineInitialiser
然而,问题是
尝试将交换解组为BindyCsvDataFormat
时出现问题。我有两个格式类文件,我为file1输入文件指定了一个,file2.csv
指定了一个。
现在,bindy正在尝试将格式映射到父类文件。但是,当它拾取file1.csv
时,它会将它映射到在同一个包下定义的model1和model2。
但是,它应该只将它映射到一个类。如何强制它只映射到一个格式类?
错误如下:
java.lang.IllegalArgumentException:缺少某些字段(可选或必填),第1行: 在org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:215) atorg.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:169)atorg.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:58) at org.apache.camel.util.AsyncProcessorConverterHelper $ ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) 在org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)位于org.apache.camel.processor.DelegateAsyncProcessor.processNext的org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) (DelegateAsyncProcessor.java:99)org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:333) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) 在org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) 在org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) 在org.apache.camel.processor.Pipeline.process(Pipeline.java:117) 在org.apache.camel.processor.Pipeline.process(Pipeline.java:80) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) 在org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) 在org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) 在org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) 在org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:50) 在org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) 在org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) 在org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352) 在org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175) 在org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136) 在org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:138) 在org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:90) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask $ Sync.innerRunAndReset(FutureTask.java:317) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 101(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205) at java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908) 在java.lang.Thread.run(Thread.java:619) |#]
答案 0 :(得分:0)
您需要为不同的bindy模型使用不同的包名称。这是目前的一个限制,并将在未来得到改善。
答案 1 :(得分:0)
不同的实体经理应该解决问题。