Skip to content

Commit 5f42dbd

Browse files
author
谭耀飞
committed
Fix springboot fails to start via JAR
1 parent 8b3cde9 commit 5f42dbd

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,21 +88,25 @@ 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);
98100
Platform.runLater(() -> errorAction.accept(throwable));
99101
} else {
102+
executor.shutdown();
100103
Platform.runLater(() -> {
101104
loadIcons(ctx);
102105
launchApplicationView(ctx);
103106
});
104107
}
105108
}).thenAcceptBothAsync(splashIsShowing, (ctx, closeSplash) -> {
109+
executor.shutdown();
106110
Platform.runLater(closeSplash);
107111
});
108112
}

0 commit comments

Comments
 (0)