Launching JavaFX 2 with Spring Boot
<p>I am trying to create new application with JavaFX 2 and Spring Boot, but so far my simple app (like hello world) isn't running because of "root is null" in <code>MainPaneController</code>.</p>

<p>MainPaneController class:</p>

<pre><code>public class MainPaneController implements Initializable {

    public static final String VIEW = "/fxml/Scene.fxml";

    @FXML
    private Node root;

    @FXML
    private Label label;

    @PostConstruct
    public void init() {
    }

    public Node getRoot() {
        return root;
    }

    @FXML
    private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");
        label.setText("Hello World!");
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }

}
</code></pre>

<p>Main class FxBootApplication:</p>

<pre><code>@SpringBootApplication
public class FxBootApplication extends Application {

    private static String[] args;

    @Override
    public void start(final Stage stage) throws Exception {
        //Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));
        // Bootstrap Spring context here.
        ApplicationContext context = SpringApplication.run(FxBootApplication.class, args);

        MainPaneController mainPaneController = context.getBean(MainPaneController.class);

        Scene scene = new Scene((Parent) mainPaneController.getRoot()); // error here

        //Scene scene = new Scene(root);
        //scene.getStylesheets().add("/styles/Styles.css");
        stage.setTitle("JavaFX and Maven");
        stage.setScene(scene);
        stage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        FxBootApplication.args = args;
        launch(args);
    }

}
</code></pre>

<p>ApplicationConfiguration class:</p>

<pre><code>@Configuration
public class ApplicationConfiguration {

    @Bean
    public MainPaneController mainPaneController() throws IOException {
        MainPaneController mpc = (MainPaneController) loadController(MainPaneController.VIEW);
        return mpc;
    }

    public &lt;T&gt; T loadController(String url) throws IOException {
        try (InputStream fxmlStream = getClass().getResourceAsStream(url)) {
            FXMLLoader loader = new FXMLLoader(getClass().getResource(url));
            //FXMLLoader.load(url);
            loader.load(fxmlStream);
            return loader.getController();
        }
    }

}
</code></pre>

<p>Error is while I am trying to get root for Scene by <code>controller.getRoot()</code>;</p>

<p>I followed the solution proposed here -> <a href="https://stackoverflow.com/questions/28804012/javafx-fxml-how-to-use-spring-di-with-nested-custom-controls/35045158#35045158">JavaFX fxml - How to use Spring DI with nested custom controls?</a> but eventually is not working for me at all. <strong>Should I somehow initialize this root before?</strong></p>