Improvement for Spring Boot Exit Codes
This commit is contained in:
parent
87111ea998
commit
164957ad0a
|
@ -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();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue