为了账号安全,请及时绑定邮箱和手机立即绑定

SpringBoot JPA repository always null

SpringBoot JPA repository always null

慕姐8265434 2019-05-23 10:54:31
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?
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 1282 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信