找不到ResourcelessTransactionManager

问题描述 投票:0回答:3

我正在尝试在 Spring boot 应用程序之上安排 Spring Batch。以下是我的配置。但是,当应用程序启动失败并出现以下错误时,我看到错误。

ScheduleConfig 中方法 mapJobRepositoryFactory 的参数 0 需要类型为“org.springframework.batch.support.transaction.ResourcelessTransactionManager”的 bean,但无法找到。有人可以解释一下为什么会发生这种情况吗?

@Configuration @EnableScheduling public class ScheduleConfig { @Bean public ResourcelessTransactionManager transactionManager() { return new ResourcelessTransactionManager(); } @Bean public MapJobRepositoryFactoryBean mapJobRepositoryFactory( ResourcelessTransactionManager transactionManager) throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(transactionManager); factory.afterPropertiesSet(); return factory; } @Bean public JobRepository jobRepository( MapJobRepositoryFactoryBean factory) throws Exception { return factory.getObject(); } @Bean public SimpleJobLauncher jobLauncher(JobRepository jobRepository) { SimpleJobLauncher launcher = new SimpleJobLauncher(); launcher.setJobRepository(jobRepository); return launcher; } }
    
java spring spring-batch
3个回答
2
投票
在类顶部添加@EnableBatchProcessing :)


0
投票
请勿使用

公共 PlatformTransactionManager 事务管理器(....

因为... 它与“DefaultBatchConfigurer”中的“PlatformTransactionManager”冲突。


0
投票
我也有类似的问题。我手动导入应用程序配置(禁用自动导入),并在单独的配置类上添加了 @EnableBatchProcessing。结果我同样的错误。通过在主配置类上添加 @EnableBatchProcessing 解决。希望这有帮助

© www.soinside.com 2019 - 2024. All rights reserved.