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
e0a1fe99
Commit
e0a1fe99
authored
Jul 13, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
f4d3e495
54a13cb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+24
-1
ExitCodeGenerator.java
...main/java/org/springframework/boot/ExitCodeGenerator.java
+1
-2
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
e0a1fe99
...
@@ -336,8 +336,31 @@ callbacks (such as the `DisposableBean` interface, or the `@PreDestroy` annotati
...
@@ -336,8 +336,31 @@ 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 return it as a status
code.
[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.
[[boot-features-application-admin]]
[[boot-features-application-admin]]
...
...
spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerator.java
View file @
e0a1fe99
...
@@ -18,8 +18,7 @@ package org.springframework.boot;
...
@@ -18,8 +18,7 @@ package org.springframework.boot;
/**
/**
* Interface used to generate an 'exit code' from a running command line
* Interface used to generate an 'exit code' from a running command line
* {@link SpringApplication}. Since 1.3.2 this interface can be used on exceptions as well
* {@link SpringApplication}. Can be used on exceptions as well as directly on beans.
* as directly on beans.
*
*
* @author Dave Syer
* @author Dave Syer
* @see SpringApplication#exit(org.springframework.context.ApplicationContext,
* @see SpringApplication#exit(org.springframework.context.ApplicationContext,
...
...
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