Я новичок в весенней партии, и я разработал простой проект с ним. Я получаю сообщение об ошибке.
Description:
Field job in com.example.demo.DemoApplication required a bean of type
'org.springframework.batch.core.Job' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.batch.core.Job' in your
configuration.
Вот мой код, у меня всего один класс:
'package com.example.demo;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@SpringBootApplication
@EnableScheduling
@EnableBatchProcessing
public class DemoApplication {
@Autowired
private JobLauncher jobLauncher;
@Autowired
private Job job;
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Scheduled(cron = "0 */1 * * * ?")
public void perform() throws Exception
{
JobParameters params = new JobParametersBuilder()
.addString("JobID", String.valueOf(System.currentTimeMillis()))
.toJobParameters();
jobLauncher.run(job, params);
}
}
Спасибо за помощь в поиске основной причины этой ошибки