Polish "Improve ExitCodeGenerator doc"

Closes gh-9740
This commit is contained in:
Stephane Nicoll
2017-07-13 09:21:36 +02:00
parent cf2ebbcb25
commit e2880ee2c3
2 changed files with 17 additions and 17 deletions

View File

@@ -337,29 +337,30 @@ be used.
In addition, beans may implement the `org.springframework.boot.ExitCodeGenerator`
interface if they wish to return a specific exit code when `SpringApplication.exit()`
is called. This exit code can then be passed to `System.exit()` to pass it to the outside.
is called. This exit code can then be passed to `System.exit()` to return it as a status
code.
[source,java,indent=0]
----
@SpringBootApplication
public class ExitCodeApplication {
public class ExitCodeApplication {
public static void main(String[] args) {
System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeApplication.class, args)));
}
public static void main(String[] args) {
System.exit(SpringApplication.exit(
SpringApplication.run(ExitCodeApplication.class, args)));
}
@Bean
public ExitCodeGenerator exitCodeGenerator(){
return () -> 42;
}
@Bean
public ExitCodeGenerator exitCodeGenerator(){
return () -> 42;
}
}
}
----
Also, the `ExitCodeGenerator` interface may be implemented by exceptions. When such an exception is
encountered, Spring Boot will return the exit code provided by the implemented `getExitCode()` method
to the outside caller.
Also, the `ExitCodeGenerator` interface may be implemented by exceptions. When such an
exception is encountered, Spring Boot will return the exit code provided by the
implemented `getExitCode()` method.
[[boot-features-application-admin]]