Spring boot 类型为';org.springframework.boot.autoconfigure.batch.BatchProperties$Job';那是找不到的

Spring boot 类型为';org.springframework.boot.autoconfigure.batch.BatchProperties$Job';那是找不到的,spring-boot,spring-data-jpa,spring-batch,Spring Boot,Spring Data Jpa,Spring Batch,开发基于XML的Spring Boot JPA批处理方法。我开发了一些代码,它开始给我下面的错误 有人能告诉我这个错误吗 理想情况下,我希望应该创建JobLauncher和JobRepository实例以供应用程序使用。这里还需要配置什么 错误: *************************** APPLICATION FAILED TO START *************************** Description: Field studentTestJob in com

开发基于XML的Spring Boot JPA批处理方法。我开发了一些代码,它开始给我下面的错误

有人能告诉我这个错误吗

理想情况下,我希望应该创建JobLauncher和JobRepository实例以供应用程序使用。这里还需要配置什么

错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field studentTestJob in com.its.example.service.HelloWorldService required a bean of type 'org.springframework.boot.autoconfigure.batch.BatchProperties$Job' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.boot.autoconfigure.batch.BatchProperties$Job' in your configuration.
H2Application.java

@SpringBootApplication
@EnableBatchProcessing
@ImportResource("classpath:applicationContext.xml")
@Import(AdditionalBatchConfiguration.class)
public class H2Application implements CommandLineRunner {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    StudentRepository repository;

    @Autowired
    HelloWorldService helloWorldService;

    public static void main(String[] args) {
        SpringApplication.run(H2Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(H2Application.class);
        ..........
        .........
    }
}
@Service
public class HelloWorldService {
    private Logger  logger = LogManager.getLogger(HelloWorldService.class.getName());

    @Autowired
    JobLauncher jobLauncher;

    @Autowired
    JobBuilderFactory jobBuilderFactory;

    @Autowired
    Job studentTestJob;

    public void testMethod() {

        logger.info(" test method in the service called");
        Map<String,String> testmsg = new HashMap<>();
        testmsg.put("KEY1", "value 1");
        testmsg.put("KEY2", "value 2");
        logger.info(testmsg);

        JobParameters jobParameters = new JobParametersBuilder().toJobParameters(); 
    }
}
HelloWorldService.java

@SpringBootApplication
@EnableBatchProcessing
@ImportResource("classpath:applicationContext.xml")
@Import(AdditionalBatchConfiguration.class)
public class H2Application implements CommandLineRunner {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    StudentRepository repository;

    @Autowired
    HelloWorldService helloWorldService;

    public static void main(String[] args) {
        SpringApplication.run(H2Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(H2Application.class);
        ..........
        .........
    }
}
@Service
public class HelloWorldService {
    private Logger  logger = LogManager.getLogger(HelloWorldService.class.getName());

    @Autowired
    JobLauncher jobLauncher;

    @Autowired
    JobBuilderFactory jobBuilderFactory;

    @Autowired
    Job studentTestJob;

    public void testMethod() {

        logger.info(" test method in the service called");
        Map<String,String> testmsg = new HashMap<>();
        testmsg.put("KEY1", "value 1");
        testmsg.put("KEY2", "value 2");
        logger.info(testmsg);

        JobParameters jobParameters = new JobParametersBuilder().toJobParameters(); 
    }
}
@服务
公共类HelloWorldService{
私有记录器Logger=LogManager.getLogger(HelloWorldService.class.getName());
@自动连线
JobLauncher JobLauncher;
@自动连线
JobBuilderFactory JobBuilderFactory;
@自动连线
职业学生测试工作;
公共void testMethod(){
logger.info(“调用服务的测试方法”);
Map testmsg=new HashMap();
testmsg.put(“键1”、“值1”);
testmsg.put(“键2”、“值2”);
logger.info(testmsg);
JobParameters JobParameters=新的JobParametersBuilder().toJobParameters();
}
}
testjob.xml

<batch:job id="StudentTestJob">
        <batch:step id="step1">
            <batch:tasklet>
                <batch:chunk reader="studentReader" writer="studentWriter"
                    processor="studentProcessor" commit-interval="10">
                </batch:chunk>
            </batch:tasklet>
        </batch:step>
</batch:job>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:annotation-config/>
    <context:property-placeholder/>

    <import resource="testjob.xml"/>    
    <bean id="helloService" class="com.its.example.service.HelloWorldService"/>
</beans>

applicationContext.xml

<batch:job id="StudentTestJob">
        <batch:step id="step1">
            <batch:tasklet>
                <batch:chunk reader="studentReader" writer="studentWriter"
                    processor="studentProcessor" commit-interval="10">
                </batch:chunk>
            </batch:tasklet>
        </batch:step>
</batch:job>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:annotation-config/>
    <context:property-placeholder/>

    <import resource="testjob.xml"/>    
    <bean id="helloService" class="com.its.example.service.HelloWorldService"/>
</beans>

尝试将
id=“StudentTestJob”
更改为小写
id=“StudentTestJob”
I second@Patrick,作业id应为
StudentTestJob
。标识符区分大小写。