Spring-batch to Spring задача в потоке данных Spring Cloud

Я новичок в потоках данных Spring-Batch и Spring Cloud. Я изменил образец проекта быстрого запуска для spring -batch, и теперь он записывает в локальную базу данных MSSQL: он отлично работает, когда я запускаю его с помощью java -jar. Теперь я попытался развернуть его в локальном экземпляре Spring Cloud Data Flow, импортировал его как задачу из панели управления и попытался запустить: он дает мне эту ошибку:

2017-11-15 17:54:46.109  INFO 17164 --- [           main] hello.Application                        : Starting Application v0.0.1-SNAPSHOT on localmachine with PID 17164 (C:\Users\massimo.sporchia\eclipse-workspace\batch-example\target\batch-example-0.0.1-SNAPSHOT.jar started by massimo.sporchia in C:\Users\MASSIM~1.SPO\AppData\Local\Temp\spring-cloud-dataflow-5975572085987003620\exampleTask-1510764882259\exampleTask-4fd22d5a-a5f0-49d5-8634-a4bbb21d2675)
2017-11-15 17:54:46.129  INFO 17164 --- [           main] hello.Application                        : No active profile set, falling back to default profiles: default
2017-11-15 17:54:46.402  INFO 17164 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1698c449: startup date [Wed Nov 15 17:54:46 CET 2017]; root of context hierarchy
2017-11-15 17:54:49.020  WARN 17164 --- [           main] o.s.c.a.ConfigurationClassEnhancer       : @Bean method ScopeConfiguration.stepScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean javadoc for complete details.
2017-11-15 17:54:49.066  WARN 17164 --- [           main] o.s.c.a.ConfigurationClassEnhancer       : @Bean method ScopeConfiguration.jobScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @Resource and @PostConstruct within the method's declaring @Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @Bean javadoc for complete details.
2017-11-15 17:54:49.288  INFO 17164 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration' of type [org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration$$EnhancerBySpringCGLIB$$da33614e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-11-15 17:54:49.306  INFO 17164 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$54c3b5c2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-11-15 17:54:49.441  INFO 17164 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.task.batch.listener.BatchEventAutoConfiguration' of type [org.springframework.cloud.task.batch.listener.BatchEventAutoConfiguration$$EnhancerBySpringCGLIB$$22896b51] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-11-15 17:54:49.631  WARN 17164 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchConfiguration': Unsatisfied dependency expressed through field 'jobBuilderFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Unsatisfied dependency expressed through field 'dataSources'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver
2017-11-15 17:54:49.653  INFO 17164 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-15 17:54:49.686 ERROR 17164 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchConfiguration': Unsatisfied dependency expressed through field 'jobBuilderFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Unsatisfied dependency expressed through field 'dataSources'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver

Тот же самый spring-batch uber-jar работает при развертывании как Stream: что мне не хватает?


person Massimo    schedule 15.11.2017    source источник
comment
Как вы регистрируете приложение spring-batch в SCDF? Он должен быть зарегистрирован как task - а вы? Это утверждение также сбивает с толку: тот же самый spring-batch uber-jar работает при развертывании как Stream - пакетное задание не может выполняться как поток. Поделитесь командами пользовательского приложения (кода), регистрации приложения, потока или определения задачи, и мы будем рады их просмотреть.   -  person Sabby Anandan    schedule 17.11.2017


Ответы (1)


Спасибо за репо.

Чтобы запустить задание Spring Batch в SCDF, вам необходимо адаптировать приложение к Spring Cloud Task модель программирования. Используйте Spring Cloud Task и Spring Cloud Примеры пакетных заданий Data Flow в качестве справки.

Если приложение не адаптируется к этой модели, оно не будет работать в SCDF.

Еще одно. Пакетное задание может выполняться только как Задача в SCDF, и его нельзя использовать в потоке.

person Sabby Anandan    schedule 17.11.2017