IhavebelowcodeController@RequestMapping("/reminder")@ResponseBodypublicStringreminder()throwsException{JobParametersjobParameters=newJobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();jobLauncher.run(job,jobParameters);return"Done";}Config@ConfigurationpublicclassBatchConfig{@AutowiredpublicJobBuilderFactoryjobBuilderFactory;@AutowiredpublicStepBuilderFactorystepBuilderFactory;@BeanpublicJobjob(){//definesajobreturnjobBuilderFactory.get("job").incrementer(newRunIdIncrementer()).flow(step1()).end().build();}@BeanpublicStepstep1(){//definesasinglestepreturnstepBuilderFactory.get("step1").chunk(1)//importanttobeoneinthiscasetocommitaftereverylineread.reader(newReader()).processor(newProcessor()).writer(newWriter()).build();}}Reader@ServicepublicclassReaderimplementsItemReader{privatestaticfinalLoggerlog=LoggerFactory.getLogger(Reader.class);@AutowiredMercRepositorymercRepository;@OverridepublicAread()throwsException,UnexpectedInputException,ParseException,NonTransientResourceException{if(mercRepository!=null){System.out.println("notnull");}else{System.out.println("null");}ListthList=mercRepository.getMer();System.out.println("thlistsize"+thList.size());return(Campaign)thList;}}Errornull2018-02-2210:05:45ERRORo.s.batch.core.step.AbstractStep-Encounteredanerrorexecutingstepstep1injobjobjava.lang.NullPointerException:nullatcom.rh.app.batch.reader.Reader.read(Reader.java:43)atcom.rh.app.batch.reader.Reader.read(Reader.java:27)atorg.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:91)atorg.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:157)atorg.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:116)atorg.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)atorg.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)atorg.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)Ihaveaddeda@Servicetoautowiredtherepository,buttheerrorstillexists.Anyadvice?
添加回答
举报
0/150
提交
取消