Spring boot + spring batch without DataSource

前端 未结 5 750
余生分开走
余生分开走 2020-12-19 00:51

I\'m trying to configure spring batch inside spring boot project and I want to use it without data source. I\'ve found that ResourcelessTransactionManager is th

5条回答
  •  不思量自难忘°
    2020-12-19 01:07

    In my case I persist data to Cassandra. If you are using spring-boot-starter-batch it is expected to provide a DataSource which is not yet implemented but you can trick the configuration like in the following steps:

    Step1:

    @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
    public class SampleSpringBatchApplication{
    
        public static void main(String[] args) {
            System.setProperty("spring.devtools.restart.enabled", "true");
            SpringApplication.run(SampleSpringBatchApplication.class, args);
        }
    
    }
    

    Step2:

        @Configuration
        @EnableBatchProcessing
        public class SampleBatchJob extends DefaultBatchConfigurer {
    
            //..
    
            @Override
            public void setDataSource(DataSource dataSource) {
            }
    
            //..
        }
    

提交回复
热议问题