我有一個(gè)罐子,里面有幾個(gè)作業(yè),我想每次只執(zhí)行一個(gè)作業(yè),并檢索一個(gè)自定義的退出代碼。例如,我有一個(gè)基本的job(retrieveErrorsJob)配置,其中一個(gè)步驟將讀取輸入的XML文件并將數(shù)據(jù)寫入特定的數(shù)據(jù)庫表中。應(yīng)用類別@SpringBootApplication@EnableBatchProcessing@Import(CoreCommonsAppComponent.class)public class Application { private static final Logger logger = LoggerFactory.getLogger(Application.class); private ConfigurationConstants constants; @Autowired public Application(ConfigurationConstants constants) { this.constants = constants; } @EventListener(ApplicationStartedEvent.class) public void idApplication() { logger.info("================================================"); logger.info(constants.APPLICATION_NAME() + "-v." + constants.APPLICATION_VERSION() + " started on " + constants.REMOTE_HOST()); logger.info("------------------------------------------------"); } public static void main(String... args) throws Exception{ ApplicationContext context = SpringApplication.run(Application.class, args); logger.info("================================================"); SpringApplication.exit(context); }}我可以從命令行選擇一項(xiàng)工作:java -jar my-jar.jar --spring.batch.job.names=retrieveErrorsJob --input.xml.file=myfile.xmlSpring Batch將啟動正確的作業(yè)。問題是我需要jar返回一個(gè)自定義進(jìn)程退出整數(shù)(如ExitCode.FAILED == 4etc),但我始終為零(如果ExitCode = SUCCESS或FAILED)。根據(jù)文檔,我需要實(shí)現(xiàn)ExitCodeMapper接口。我找不到使用此自定義實(shí)現(xiàn)的方法。我可以將自定義實(shí)現(xiàn)設(shè)置為,CommandLineJobRunner但是如何使用此類?
添加回答
舉報(bào)
0/150
提交
取消