diff --git a/2023-01/spring-28-spring-batch/pom.xml b/2023-01/spring-28-spring-batch/pom.xml
index a433023a..8b8ebfe0 100644
--- a/2023-01/spring-28-spring-batch/pom.xml
+++ b/2023-01/spring-28-spring-batch/pom.xml
@@ -11,7 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.6
+ 3.1.0
@@ -25,20 +25,14 @@
-
- org.springframework.boot
- spring-boot-starter
-
-
-
- org.springframework.boot
- spring-boot-starter-jdbc
-
-
org.springframework.boot
spring-boot-starter-batch
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
com.h2database
diff --git a/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/config/BatchConfig.java b/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/config/BatchConfig.java
index 802d2111..7c9ce9ec 100644
--- a/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/config/BatchConfig.java
+++ b/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/config/BatchConfig.java
@@ -1,27 +1,11 @@
package ru.otus.example.springbatch.config;
import org.springframework.batch.core.configuration.JobRegistry;
-import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor;
-import org.springframework.batch.core.explore.JobExplorer;
-import org.springframework.batch.core.launch.JobLauncher;
-import org.springframework.batch.core.repository.JobRepository;
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.batch.BatchDataSource;
-import org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer;
-import org.springframework.boot.autoconfigure.batch.BatchProperties;
-import org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.util.StringUtils;
-import javax.sql.DataSource;
-
-@EnableBatchProcessing
-@EnableConfigurationProperties(BatchProperties.class)
+@SuppressWarnings("unused")
@Configuration
public class BatchConfig {
@Bean
@@ -30,24 +14,4 @@ public class BatchConfig {
processor.setJobRegistry(jobRegistry);
return processor;
}
- @Bean
- @ConditionalOnMissingBean
- @ConditionalOnProperty(prefix = "spring.batch.job", name = "enabled", havingValue = "true", matchIfMissing = true)
- public JobLauncherApplicationRunner jobLauncherApplicationRunner(JobLauncher jobLauncher, JobExplorer jobExplorer,
- JobRepository jobRepository, BatchProperties properties) {
- JobLauncherApplicationRunner runner = new JobLauncherApplicationRunner(jobLauncher, jobExplorer, jobRepository);
- String jobNames = properties.getJob().getName();
- if (StringUtils.hasText(jobNames)) {
- runner.setJobName(jobNames);
- }
- return runner;
- }
-
- @Bean
- @ConditionalOnMissingBean(BatchDataSourceScriptDatabaseInitializer.class)
- public BatchDataSourceScriptDatabaseInitializer batchDataSourceInitializer(DataSource dataSource,
- @BatchDataSource ObjectProvider batchDataSource, BatchProperties properties) {
- return new BatchDataSourceScriptDatabaseInitializer(batchDataSource.getIfAvailable(() -> dataSource),
- properties.getJdbc());
- }
}
diff --git a/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/service/CleanUpService.java b/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/service/CleanUpService.java
index cd659fbc..9b88036d 100644
--- a/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/service/CleanUpService.java
+++ b/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/service/CleanUpService.java
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
@Service
public class CleanUpService {
+ @SuppressWarnings("unused")
public void cleanUp() throws Exception {
log.info("Выполняю завершающие мероприятия...");
Thread.sleep(1000);
diff --git a/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/shell/BatchCommands.java b/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/shell/BatchCommands.java
index 763eea58..a8f9db2c 100644
--- a/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/shell/BatchCommands.java
+++ b/2023-01/spring-28-spring-batch/src/main/java/ru/otus/example/springbatch/shell/BatchCommands.java
@@ -11,6 +11,8 @@ import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import ru.otus.example.springbatch.config.AppProps;
+import java.util.Properties;
+
import static ru.otus.example.springbatch.config.JobConfig.IMPORT_USER_JOB_NAME;
import static ru.otus.example.springbatch.config.JobConfig.INPUT_FILE_NAME;
import static ru.otus.example.springbatch.config.JobConfig.OUTPUT_FILE_NAME;
@@ -28,6 +30,8 @@ public class BatchCommands {
//http://localhost:8080/h2-console/
+
+ @SuppressWarnings("unused")
@ShellMethod(value = "startMigrationJobWithJobLauncher", key = "sm-jl")
public void startMigrationJobWithJobLauncher() throws Exception {
JobExecution execution = jobLauncher.run(importUserJob, new JobParametersBuilder()
@@ -37,15 +41,18 @@ public class BatchCommands {
System.out.println(execution);
}
+ @SuppressWarnings("unused")
@ShellMethod(value = "startMigrationJobWithJobOperator", key = "sm-jo")
public void startMigrationJobWithJobOperator() throws Exception {
- Long executionId = jobOperator.start(IMPORT_USER_JOB_NAME,
- INPUT_FILE_NAME + "=" + appProps.getInputFile() + "\n" +
- OUTPUT_FILE_NAME + "=" + appProps.getOutputFile()
- );
+ Properties properties = new Properties();
+ properties.put(INPUT_FILE_NAME, appProps.getInputFile());
+ properties.put(OUTPUT_FILE_NAME, appProps.getOutputFile());
+
+ Long executionId = jobOperator.start(IMPORT_USER_JOB_NAME, properties);
System.out.println(jobOperator.getSummary(executionId));
}
+ @SuppressWarnings("unused")
@ShellMethod(value = "showInfo", key = "i")
public void showInfo() {
System.out.println(jobExplorer.getJobNames());