Nullpointerexception spring批处理空作业运行程序空指针异常
嗨,我在执行示例spring批处理作业时遇到空指针异常。从作业启动程序引发异常。这是我的作业启动程序代码。提前谢谢Nullpointerexception spring批处理空作业运行程序空指针异常,nullpointerexception,jobs,spring-batch,runner,Nullpointerexception,Jobs,Spring Batch,Runner,嗨,我在执行示例spring批处理作业时遇到空指针异常。从作业启动程序引发异常。这是我的作业启动程序代码。提前谢谢 public class NewJobRunner { public static Job job; public static JobLauncher jobLauncher; public static JobRepository jobRepository; public static void main(String args[]) { try {
public class NewJobRunner {
public static Job job;
public static JobLauncher jobLauncher;
public static JobRepository jobRepository;
public static void main(String args[]) {
try {
AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("/resources/job-context.xml");
jobLauncher.run(job, new JobParametersBuilder()
.toJobParameters()
);
}catch(Exception e) {
e.printStackTrace();
}
}
public void setJobLauncher(JobLauncher jobLauncher) {
this.jobLauncher = jobLauncher;
}
public void setJobRepository(JobRepository jobRepository) {
this.jobRepository = jobRepository;
}
public void setJob(Job job) {
this.job = job;
}
嗯,你们所有的成员都是静态的;基本上,如果您在job-context.xml中有正确的配置,这可能会工作,但不应该这样工作。我建议你为会员去掉静电;在作业上下文中声明一个NewJobRunner;注入所有成员,然后注入NewJobRunner=(NewJobRunner)applicationContext.getBean(“NewJobRunner”);运行(job,newjobParametersBuilder().toJobParameters());在哪一点上出现空点异常?请共享异常详细信息。错误可能是由于路径“/resources/job context.xml”无效造成的