У меня есть следующий класс конфигурации весной партия:Spring исключение конфигурации Batch
@Configuration
@EnableBatchProcessing
public class BatchJobConfiguration {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean
public Step step1() {
return stepBuilderFactory.get("step1")
.tasklet(new Tasklet() {
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) {
return null;
}
})
.build();
}
@Bean
public Job job(Step step1) throws Exception {
return jobBuilderFactory.get("job1")
.incrementer(new RunIdIncrementer())
.start(step1)
.build();
}
}
Когда я начинаю мое заявление я получаю следующее исключение:
Вызванный: java.lang.ClassCastException: орг. springframework.data.jpa.repository.support.JpaRepositoryFactoryBean $$ EnhancerBySpringCGLIB $$ 65a19538 не может быть приведен к org.springframework.batch.core.repository.JobRepository на org.springframework.batch.core.configu ration.annotation.SimpleBatchConfiguration $$ EnhancerBySpringCGLIB $$ 14f7a80d.jobRepository() на org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.jobBuilders (AbstractBatchConfiguration.java:58) в org.springframework.batch.core .configuration.annotation.SimpleBatchConfiguration $$ EnhancerBySpringCGLIB $$ 14f7a80d.CGLIB $ jobBuilders $ 6() в org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration $$ EnhancerBySpringCGLIB $$ 14f7a80d $$ FastClassBySpringCGLIB $$ c6b630d7.invoke () по адресу org.springframework.cglib.proxy.MethodProxy.invokeSuper (MethodProxy.java:228) по адресу org.springframework.context.annotation.ConfigurationClassEnhancer $ BeanMethodInterceptor.intercept (ConfigurationClassEnhancer.java:312) в org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration $$ EnhancerBySpringCGLIB $$ 14f7a80d.jobBuilders() в sun.reflect.NativeMethodAccessorImpl.invoke0 (метод Native) в sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) на sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) в java.lang.reflect.Method.invoke (Method.java:497) на org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate (SimpleInstantiationStrategy.java:162)
В pom.xml У меня есть следующая зависимость:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
Спасибо заранее.
Есть ли у вас переменная JpaRepositoryFactoryBean в любом месте вашего кода? Если да, напишите эту строку. –
Нет, у меня нет такой переменной. – Iurii
Извините, я был невнимателен. Я нашел интерфейс JobRepository, который расширяет JpaRepository (SpringData). Поэтому я переименовываю JobRepository, и все становится хорошо. Пожалуйста, ответьте на мой вопрос, и я закрою свой пост. – Iurii