Merge pull request #9839 from alimate/BAEL-4537
BAEL-4537: Improvement for Spring Boot Exit Codes
This commit is contained in:
		
						commit
						d22422f8e2
					
				| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user