Skip to content

Commit 1f30ab0

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

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,10 +88,12 @@ 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);
@@ -104,6 +106,8 @@ public void init() throws Exception {
104106
}
105107
}).thenAcceptBothAsync(splashIsShowing, (ctx, closeSplash) -> {
106108
Platform.runLater(closeSplash);
109+
// Shutdown the executor otherwise the application will never exit.
110+
executor.shutdown();
107111
});
108112
}
109113

0 commit comments

Comments
 (0)