Skip to content

Commit 859fd0e

Browse files
author
谭耀飞
committedOct 18, 2022
Fix springboot fails to start via JAR
1 parent 8b3cde9 commit 859fd0e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎src/main/java/de/felixroske/jfxsupport/AbstractJavaFxApplicationSupport.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@ private void loadIcons(ConfigurableApplicationContext ctx) {
8888
*/
8989
@Override
9090
public void init() throws Exception {
91-
// Load in JavaFx Thread and reused by Completable Future, but should no be a big deal.
91+
// Load in JavaFx Thread and reused by Completable Future, but should not be a big deal.
92+
// Provide an executor instead of using default, otherwise spring application will fail to start via JAR(mvn package)
93+
ExecutorService executor = Executors.newSingleThreadExecutor();
9294
defaultIcons.addAll(loadDefaultIcons());
9395
CompletableFuture.supplyAsync(() ->
94-
SpringApplication.run(this.getClass(), savedArgs)
96+
SpringApplication.run(this.getClass(), savedArgs), executor
9597
).whenComplete((ctx, throwable) -> {
9698
if (throwable != null) {
9799
LOGGER.error("Failed to load spring application context: ", throwable);
100+
executor.shutdown();
98101
Platform.runLater(() -> errorAction.accept(throwable));
99102
} else {
100103
Platform.runLater(() -> {
@@ -103,6 +106,7 @@ public void init() throws Exception {
103106
});
104107
}
105108
}).thenAcceptBothAsync(splashIsShowing, (ctx, closeSplash) -> {
109+
executor.shutdown();
106110
Platform.runLater(closeSplash);
107111
});
108112
}

0 commit comments

Comments
 (0)
Please sign in to comment.