Make a spring-batch job exit with non-zero code if an exception is thrown

前端 未结 3 1260
醉梦人生
醉梦人生 2020-12-18 11:32

I\'m trying to fix a spring-batch job which is launched from a shell script. The script then checks the process exit code to determine whether the job has succeeded. Java, h

3条回答
  •  难免孤独
    2020-12-18 12:00

    As per this github issue it's recommended to pass the result of SpringApplication#exit to System#exit. You don't need to access an ExitCodeGenerator instance directly or manually close the context.

    ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
    int exitCode = SpringApplication.exit(context);
    System.exit(exitCode);
    

提交回复
热议问题