Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
cf2ebbcb
Commit
cf2ebbcb
authored
Jul 12, 2017
by
Tom Hombergs
Committed by
Stephane Nicoll
Jul 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve ExitCodeGenerator doc
See gh-9740
parent
76c21eab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+23
-1
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
cf2ebbcb
...
@@ -336,7 +336,29 @@ callbacks (such as the `DisposableBean` interface, or the `@PreDestroy` annotati
...
@@ -336,7 +336,29 @@ callbacks (such as the `DisposableBean` interface, or the `@PreDestroy` annotati
be used.
be used.
In addition, beans may implement the `org.springframework.boot.ExitCodeGenerator`
In addition, beans may implement the `org.springframework.boot.ExitCodeGenerator`
interface if they wish to return a specific exit code when the application ends.
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.
[source,java,indent=0]
----
@SpringBootApplication
public class ExitCodeApplication {
public static void main(String[] args) {
System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeApplication.class, args)));
}
@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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment