The SpringApplication.exit method seems quite hard to read. We currently document that it can be used as follows:
System.exit(SpringApplication.exit(SpringApplication.run(MyExitCodeApplication.class, args)));
It feels like a runAndExit method might be helpful:
SpringApplication.runAndExit(MyExitCodeApplication.class, args);
Comment From: wilkinsona
What should we do about the exit code generators? Both run and exit have varargs variants:
ConfigurableApplicationContext run(Class<?> primarySource, String... args)
int exit(ApplicationContext context, ExitCodeGenerator... exitCodeGenerators)
I suspect having additional generators (beyond those that are beans) is unusual so we could have what Phil proposed above:
int runAndExit(Class<?> primarySource, String... args)
Then perhaps we should have one or more of these as well:
int runAndExit(Class<?> primarySource, ExitCodeGenerators exitCodeGenerator, String... args)
int runAndExit(Class<?> primarySource, Collection<ExitCodeGenerator> exitCodeGenerators, String... args)