我有一個罐子,里面有幾個作業,我想每次只執行一個作業,并檢索一個自定義的退出代碼。例如,我有一個基本的job(retrieveErrorsJob)配置,其中一個步驟將讀取輸入的XML文件并將數據寫入特定的數據庫表中。應用類別@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); }}我可以從命令行選擇一項工作:java -jar my-jar.jar --spring.batch.job.names=retrieveErrorsJob --input.xml.file=myfile.xmlSpring Batch將啟動正確的作業。問題是我需要jar返回一個自定義進程退出整數(如ExitCode.FAILED == 4etc),但我始終為零(如果ExitCode = SUCCESS或FAILED)。根據文檔,我需要實現ExitCodeMapper接口。我找不到使用此自定義實現的方法。我可以將自定義實現設置為,CommandLineJobRunner但是如何使用此類?
添加回答
舉報
0/150
提交
取消