任何人都可以帮我吗,我做了spring批处理编码,但是只是执行了工作,我想执行一个.bat文件,但没有执行.bat文件。 如何在Spring Batch中执行文件.bat?我想在angular的脚本字段中运行.bat文件。
我正在使用Spring Batch和Angle。
请帮助我。
@Configuration
@EnableBatchProcessing
public class BatchConfiguration {
@Autowired
public JobBuilderFactory jobBuilderFactory;
@Autowired
public StepBuilderFactory stepBuilderFactory;
@Autowired
DataSource dataSource;
private static final String QUERY_FIND_TACHES =
"select * from hr.task";
@Bean
public ItemReader<Task> taskItemReader() {
JdbcCursorItemReader<Task> databaseReader = new JdbcCursorItemReader<>();
databaseReader.setDataSource(dataSource);
databaseReader.setSql(QUERY_FIND_TACHES);
databaseReader.setRowMapper(new TaskRowMapper());
return databaseReader;
}
@Bean
public TaskItemProcessor processor() {
return new TaskItemProcessor();
}
@Bean
public ItemWriter<Task> itemWriter(TaskRepository taskRepository) {
return new ItemWriter<Task>() {
private int task = 0;
@Override
public void write(List<? extends Task> items) throws Exception {
task += items.size();
System.out.println("written " + task + " brackets");
}
};
}
@Bean
public Step step1(ItemReader<Task> taskItemReader, ItemWriter<Task> itemWriter) {
return stepBuilderFactory.get("step1")
.<Task, Task> chunk(10)
.reader(taskItemReader)
.processor(processor())
.writer(itemWriter)
.build();
}
@Bean
public Job testJob(JobCompletionNotificationListener listener, Step step1) {
return jobBuilderFactory.get("testJob")
.incrementer(new RunIdIncrementer())
//.listener(listener)
.flow(step1)
.end()
.build();
}
和代码taskRowMapper
public class TaskRowMapper implements RowMapper<Task>{
@Override
public Task mapRow(ResultSet rs, int rowNum) throws SQLException {
Task task = new Task();
task.setId(rs.getInt("id"));
task.setNom_job(rs.getString("nom_job"));
task.setDescription(rs.getString("description"));
task.setScript(rs.getString("script"));
task.setDate_execution(rs.getDate("date_execution"));
return task;
}
}