0

我正在编写一个简单的 Spring Batch 应用程序,它从文件中读取数据并将其写入 Cassandra DB。

如果我在一个简单的 java 项目中运行 Cassandra CRUD 操作,并且只有一个以下依赖项,我就能够正确运行它。我可以成功执行 CRUD 操作。

依赖:com.impetus.client kundera-cassandra 2.5

现在问题来了!

我正在将相同的代码与 Spring Batch 应用程序集成。我最终得到以下例外:

10:22:19,816 DEBUG ThreadPoolTaskExecutor-1 dao.JdbcStepExecutionDao:203 - Truncating long message before update of StepExecution, original message is: org.springframework.batch.core.JobExecutionException: Partition handler returned an unsuccessful step
    at org.springframework.batch.core.partition.support.PartitionStep.doExecute(PartitionStep.java:110)
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:196)
    at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:375)
    at org.springframework.batch.core.job.flow.FlowJob.access$100(FlowJob.java:43)
    at org.springframework.batch.core.job.flow.FlowJob$JobFlowExecutor.executeStep(FlowJob.java:135)
    at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
    at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
    at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
    at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:103)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:266)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:118)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
; com.impetus.kundera.KunderaException: com.impetus.kundera.KunderaException: Entitymatadata should not be null
    at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:174)
    at org.springframework.batch.admin.zipfeed.ZipLocationFeedWriter.write(ZipLocationFeedWriter.java:37)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

现在我进一步比较了这两个应用程序的调试。运行 Spring Batch 应用程序时,看起来下面的注释没有得到反映。仅供参考,我提供了用于执行 CRUD 操作的 bean。相同的 bean 适用于独立应用程序 (jUnit)。

请让我知道如何使它工作。看起来注释在运行批处理应用程序时没有得到反映。(仅供参考,为了便于理解,我也截取了屏幕截图)

   @Entity
   @Table(name = "ZipLookUp", schema = "ZipDB@cassandra_pu")
   public class ZipLocationBean {

          @Id
          @Column(name = "ZIP_CODE")
          private String zipcode;
          @Column(name = "CITY")
          private String city;
          @Column(name = "STATE")
          private String state;
          @Column(name = "COUNTRY")
          private String country;
          @Column(name = "LATITUDE")
          private double latitude;
          @Column(name = "LONGITUDE")
          private double longitude;
          // Getters and setters;
   }
4

1 回答 1

0

请确认您是否有:

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> 存在于弹簧配置中。

-维维克

于 2013-05-05T16:46:42.737 回答