Skip to content

Instantly share code, notes, and snippets.

@3gcodes
Created February 6, 2017 18:28
Show Gist options
  • Save 3gcodes/05e5f125ff0f2f8afbfb1267c64b5d1e to your computer and use it in GitHub Desktop.
Save 3gcodes/05e5f125ff0f2f8afbfb1267c64b5d1e to your computer and use it in GitHub Desktop.
@SpringBootApplication
public class DemoApplication extends Application {
private ConfigurableApplicationContext springContext;
private Parent root;
@Override
public void init() throws Exception {
springContext = SpringApplication.run(DemoApplication.class);
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/sample.fxml"));
fxmlLoader.setControllerFactory(springContext::getBean);
root = fxmlLoader.load();
}
@Override
public void start(Stage primaryStage) throws Exception{
primaryStage.setTitle("Hello World");
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
@Override
public void stop() throws Exception {
springContext.stop();
}
public static void main(String[] args) {
launch(DemoApplication.class, args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment