Tag: spring batch admin

无法将’org.springframework.batch.item.xml.StaxEventItemWriter’类型的值转换为必需的类型’org.springframework.batch.item.ItemReader’

我正在开发Spring Batch MongoDB to XML示例。 我已经成功创建了这个项目,但是当我运行它时,我看到下面的错误即将来临,我不知道这里出了什么问题。 参考错误 Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘step1’: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type ‘org.springframework.batch.item.xml.StaxEventItemWriter’ to required type ‘org.springframework.batch.item.ItemReader’ for property ‘itemReader’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘org.springframework.batch.item.xml.StaxEventItemWriter’ to required type ‘org.springframework.batch.item.ItemReader’ […]

Spring Batch – 进程在哪里运行

我试图围绕Spring Batch,虽然很多教程都展示了很好的代码示例,但我觉得我很想念“spring batch engine”是如何工作的。 场景1 – 在用户创建时,在外部服务上创建用户。 网络请求 CreateLocalUser() 启动作业CreateExternalUser() 由于许多原因,CreateExternalUser()可能会失败,因此我们希望能够重试并记录Spring Batch可以为我们执行的错误。 它也是一个与我们本地用户的创建无关的解耦过程。 工作在哪里? 它是否会与Web请求在同一个线程中运行,这意味着最终用户必须等待作业完成才能获得http状态200? 想象一下,我有一个Web服务器和一个批处理服务器。 我希望所有作业都在批处理服务器上运行,但作业本身可以从Web服务器启动。 Spring Batch可以这样做吗? 我是否需要某种可以从Web服务器写入的队列和来自批处理服务器的消费,实际的工作将从哪里开始? 场景2 – 在巨大的文件中处理行,为每一行开始新的工作 读取大文件中的行(1.000.000行) 使用文件中的输入参数为每一行开始新作业。 处理1.000.000行很快,同时启动1.000.000个新作业或多或少。 这些运行在哪里? 他们是否与初始工作异步? 我的服务器是否能够同时或多或少地处理所有这些操作。 其他问题:是否可以根据作业输入参数查询作业。 即场景1,我想在我的网页上查看ID为1234的本地用户时显示CreateExternalUser作业状态/错误。 CreateExternalUser作业具有输入参数userId:1234

如何使用spring Batch注释将Job参数传递到项目处理器

我正在使用spring MVC。 从我的控制器,我正在调用jobLauncher和jobLauncher我传递的作业参数如下,我正在使用注释来启用配置如下: @Configuration @EnableBatchProcessing public class BatchConfiguration { // read, write ,process and invoke job } JobParameters jobParameters = new JobParametersBuilder().addString(“fileName”, “xxxx.txt”).toJobParameters(); stasrtjob = jobLauncher.run(job, jobParameters); and here is my itemprocessor public class DataItemProcessor implements ItemProcessor { public OutPutData process(final InputData inputData) throws Exception { // i want to get job Parameters here ???? […]

如何使用springbatch从xls导入mysql数据库?

我正在尝试创建一个接收.xlsx文件作为输入的api。 文件中的数据导入mysql数据库。 已经完成了一些教程。 能够在硬编码文件路径时使其完美运行,并且一旦服务器启动,它就会成功执行。 但是当我尝试从用户和进程接收文件时,我收到错误。 此外,我没有找到相同的资源。 下面是我的代码和错误。 @Controller public class FileController1 { @Autowired private JobLauncher jobLauncher; @Autowired private Job importUserJob; @Autowired public JobBuilderFactory jobBuilderFactory; @Autowired public StepBuilderFactory stepBuilderFactory; @Autowired ExcelFileToDatabaseJobConfig excelFileToDatabaseJobConfig; @Bean ItemReader excelStudentReader(@Value(“#{jobParameters[fullPathFileName]}”) String pathToFile) throws Exception{ System.out.println(“inside excelStudentReader”); PoiItemReader reader = new PoiItemReader(); reader.setLinesToSkip(1); reader.setResource(new ClassPathResource(pathToFile)); //reader.setResource(new UrlResource(“file:///D:/joannes/ee.xlsx”)); reader.setRowMapper(excelRowMapper()); return reader; } private […]

Spring Batch – MongoDB到XML – 引起:java.lang.IllegalStateException:需要将输入转换为的类型

我正在开发Spring Batch – MongoDB to XML例子。 在这个例子中,当我运行main方法时,我看到下面的错误是cominng。 请指导以下错误。 我试图在网上找到解决方案,但我还没有在网上找到任何有用的东西。 Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘step1’: Cannot resolve reference to bean ‘mongodbItemReader’ while setting bean property ‘itemReader’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mongodbItemReader’ defined in class path resource [job-report.xml]: Invocation of init method failed; nested exception is […]

如何在运行并行作业时安全地将params从Tasklet传递到步骤

我试图安全地将params从tasklet传递到同一工作中的一个步骤。 我的工作包括3个tasklet(第1步,第2步,第3步),最后是step4(处理器,读者,作者) 这项工作正在多次并行执行。 在tasklet里面的第一步我通过web服务评估param(hashId),而不是把它传遍整个链,直到我的读者(在第4步) 在第3步中,我创建了一个名为:filePath的新参数,该文件基于hashid,我将其作为文件资源位置发送到step4(读取器) 我正在使用stepExecution传递此参数(hashId和filePath)。 我通过tasklet尝试了3种方法: 传递param(hash1d从step1进入step2,从step2进入步骤3)我这样做: chunkContext.getStepContext() .getStepExecution() .getExecutionContext() .put(“hashId”, hashId); 在第4步中,我将基于hashId填充filePath并将其传递给我的最后一步(读者处理器和编写器) public class DownloadFileTasklet implements Tasklet, StepExecutionListener { .. @Override public RepeatStatus execute(ChunkContext chunkContext, ExecutionContext executionContext) throws IOException { String hashId = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().get(“hashId”); … filepath=”…hashId.csv”; //I used here executionContextPromotionListener in order to promote those keys chunkContext.getStepContext() .getStepExecution() .getExecutionContext() .put(“filePath”, filePath); } logger.info(“filePath […]

有没有办法正确地集成spring-batch-admin和spring-boot?

根据文档 spring批处理管理员很容易嵌入到现有的应用程序中。 只需复制web.xml和index.jsp,然后添加所需的依赖项即可使其正常工作。 但是,如果我想在现有的春季启动项目中使用它,它会变得更糟。 根据这个例子 ,配置有点hacky但它​​的工作原理。 我尝试在配置bean中使用@EnableBatchProcessing注释。 然后我得到以下exception。 Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jobBuilders’ defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.batch.core.configuration.annotation.JobBuilderFactory org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.jobBuilders() throws java.lang.Exception] threw exception; nested exception is java.lang.ClassCastException: org.springframework.batch.core.repository.support.JobRepositoryFactoryBean$$EnhancerBySpringCGLIB$$49fa0273 cannot be cast to org.springframework.batch.core.repository.JobRepository at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597) at […]

Bean属性不可读或具有无效的getter方法:getter的返回类型是否与setter的参数类型匹配? 春批

我正在开发Spring Batch CompositeItemReader & Writer示例。 我开发了XML文件并且能够成功编译代码,但是当运行mu示例代码时,会出现以下错误。 不确定出了什么问题? org.springframework.beans.NotReadablePropertyException: Invalid property ‘customerNumber’ of bean class [java.lang.String]: Bean property ‘customerNumber’ is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:619) at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:610) at org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor.extract(BeanWrapperFieldExtractor.java:57) at org.springframework.batch.item.file.transform.ExtractorLineAggregator.aggregate(ExtractorLineAggregator.java:54) at org.springframework.batch.item.file.FlatFileItemWriter.write(FlatFileItemWriter.java:267) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at […]

在单个Weblogic域中的同一群集中部署两个Spring批处理应用程序?

背景 – 我试图在一个Weblogic域中的同一个集群中部署两个Spring批处理应用程序作为.war,并且每个应用程序都在servlet.xml中配置了弹出批处理管理控制台,如下所示 – 它的maven项目和spring-batch-admin-manager 1.2.2作为依赖项被引入。 问题 – 我正在努力让他们两个同时运行。 目前我不能让他们两个一起跑,当我尝试启动另一个,而其中一个已经在运行时,我得到以下错误 – weblogic.application.ModuleException: [HTTP:######]Servlet: “myServlet” failed to preload on startup in Web application: “myservice-app.war”. org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘messageSource’ defined in URL [zip:/myservice-app_3.0.0-SNAPSHOT/yvcbfs/war/WEB-INF/lib/spring-batch-admin-manager-1.2.2.RELEASE.jar!/META-INF/spring/batch/servlet/manager/controller-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mbeanExporter’: Invocation of init method failed; nested exception […]