Merge pull request #9839 from alimate/BAEL-4537

BAEL-4537: Improvement for Spring Boot Exit Codes
This commit is contained in:
Eric Martin 2020-08-11 23:53:31 -05:00 committed by GitHub
commit d22422f8e2
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.baeldung.exitcode.exceptionexitgen;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class ExceptionExitCodeGeneratorApplication {
public static void main(String[] args) {
SpringApplication.run(ExceptionExitCodeGeneratorApplication.class, args);
}
@Bean
CommandLineRunner failApplication() {
return args -> {
throw new FailedToStartException();
};
}
}

View File

@ -0,0 +1,11 @@
package com.baeldung.exitcode.exceptionexitgen;
import org.springframework.boot.ExitCodeGenerator;
public class FailedToStartException extends RuntimeException implements ExitCodeGenerator {
@Override
public int getExitCode() {
return 127;
}
}