Springboot:org.springframework.beans.factory.BeanCreationException: Error creating bean with name...
I found the following error in springboot application. The error part in FXMLController.java is uploaded here. Also uploaded its necessary files. I'am trying to connect java and fxml file. Kindly help me. Thanks in advance
LibraryAutomationApplication.java
package com.alphabot.library;
import java.io.IOException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import javafx.application.Application;
import javafx.stage.Stage;
@SpringBootApplication
public class LibraryAutomationApplication extends Application {
protected ConfigurableApplicationContext springContext;
protected StageManager stageManager;
@Override
public void init() throws Exception {
springContext = springBootApplicationContext();
}
@Override
public void start(Stage stage) throws IOException {
stageManager = springContext.getBean(StageManager.class, stage);
//stage.setResizable(false);
//stage.setFullScreen(true);
showLoginView();
stage.setMinWidth(1000);
stage.setMinHeight(650);
}
private void showLoginView() throws IOException {
stageManager.switchScene(FxmlView.MAIN);
}
public static void main(final String args) {
launch(args);
}
@Override
public void stop() throws Exception {
springContext.close();
}
private ConfigurableApplicationContext springBootApplicationContext() {
SpringApplicationBuilder builder = new SpringApplicationBuilder(LibraryAutomationApplication.class);
String args = getParameters().getRaw().stream().toArray(String::new);
return builder.run(args);
}
}
AppJavaConfig.java
package com.alphabot.library.config;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ResourceBundle;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import com.alphabot.library.logging.ExceptionWriter;
@Configuration
public class AppJavaConfig {
@Autowired
SpringFXMLLoader springFXMLLoader;
@Bean
@Scope("prototype")
public ExceptionWriter exceptionWriter() {
return new ExceptionWriter(new StringWriter());
}
@Bean
public ResourceBundle resourceBundle() {
return ResourceBundle.getBundle("Bundle");
}
@Bean
@Lazy(value = true)
public StageManager stageManager(Stage stage) throws IOException {
return new StageManager(springFXMLLoader, stage);
}
}
SpringFXMLLoader.java
package com.alphabot.library.config;
import java.io.IOException;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@Component
public class SpringFXMLLoader {
private final ResourceBundle resourceBundle;
private final ApplicationContext context;
@Autowired
public SpringFXMLLoader(ApplicationContext context, ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
this.context = context;
}
public Parent load(String fxmlPath) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setControllerFactory(context::getBean);
loader.setResources(resourceBundle);
loader.setLocation(getClass().getResource(fxmlPath));
return loader.load();
}
}
StageManager.java
package com.alphabot.library.config;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Objects;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.alphabot.library.view.FxmlView;
import com.alphabot.library.config.StageManager;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class StageManager {
private static final Logger LOG = getLogger(StageManager.class);
private SpringFXMLLoader springFXMLLoader;
private final Stage primaryStage;
public StageManager(SpringFXMLLoader springFXMLLoader, Stage stage) {
this.springFXMLLoader = springFXMLLoader;
this.primaryStage = stage;
}
@Autowired
public Node switchScene(final FxmlView view) {
Parent viewRootNodeHierarchy = loadViewNodeHierarchy(view.getFxmlFile());
show(viewRootNodeHierarchy, view.getTitle());
return viewRootNodeHierarchy;
}
private void show(final Parent rootnode, String title) {
Scene scene = prepareScene(rootnode);
primaryStage.setTitle(title);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.centerOnScreen();
try {
primaryStage.show();
} catch (Exception exception) {
logAndExit ("Unable to show scene for title" + title, exception);
}
}
private Scene prepareScene(Parent rootnode){
Scene scene = primaryStage.getScene();
if (scene == null) {
scene = new Scene(rootnode);
}
scene.setRoot(rootnode);
return scene;
}
private Parent loadViewNodeHierarchy(String fxmlFilePath) {
Parent rootNode = null;
try {
rootNode = springFXMLLoader.load(fxmlFilePath);
Objects.requireNonNull(rootNode, "A Root FXML node must not be null");
} catch (Exception exception) {
logAndExit("Unable to load FXML view" + fxmlFilePath, exception);
}
return rootNode;
}
private void logAndExit(String errorMsg, Exception exception) {
LOG.error(errorMsg, exception, exception.getCause());
Platform.exit();
}
}
FXMLController.java
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@Component
public class FXMLController implements Initializable {
protected StageManager stageManager;
protected ConfigurableApplicationContext springContext;
@FXML
private StackPane mainPane;
@FXML
private JFXButton btnHome;
@FXML
private JFXButton btnAuthors;
@FXML
private JFXButton btnBooks;
@FXML
private JFXButton btnJournals;
@FXML
private JFXButton btnIssueReturn;
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void homeOnAction(ActionEvent event) {
Stage stage = (Stage) btnHome.getScene().getWindow();
stage.setTitle("Library Management- Home");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(showAuthorsView());
}
@Bean
private Node showAuthorsView() throws IOException {
stageManager = springContext.getBean(StageManager.class, mainPane);
return stageManager.switchScene(FxmlView.AUTHORS);
}
@FXML
private void booksOnAction(ActionEvent event) {
// Stage stage = (Stage) btnBooks.getScene().getWindow();
// stage.setTitle("Library Management- Books");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/BooksPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void journalsOnAction(ActionEvent event) {
Stage stage = (Stage) btnJournals.getScene().getWindow();
stage.setTitle("Library Management- Journals");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/JournalsPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void issueReturnOnAction(ActionEvent event) {
Stage stage = (Stage) btnIssueReturn.getScene().getWindow();
stage.setTitle("Library Management- Issue or Return");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/IssueReturnPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
ExceptionWriter.java
package com.alphabot.library.logging;
import java.io.PrintWriter;
import java.io.Writer;
public class ExceptionWriter extends PrintWriter {
public ExceptionWriter(Writer writer) {
super(writer);
}
private String wrapAroundWithNewlines(String stringWithoutNewlines) {
return ("n" + stringWithoutNewlines + "n");
}
public String getExceptionAsString(Throwable throwable) {
throwable.printStackTrace(this);
String exception = super.out.toString();
return (wrapAroundWithNewlines(exception));
}
}
FxmlView.java
package com.alphabot.library.view;
import java.util.ResourceBundle;
public enum FxmlView {
LOGIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/Login.fxml";
}
},
MAIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/MainPanel.fxml";
}
},
AUTHORS {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/AuthorsPanel.fxml";
}
},
FPASS {
@Override
public String getTitle() {
return getStringFromResourceBundle("forgotPassword.title");
}
@Override
public String getFxmlFile() {
return "/fxml/ForgotPassword.fxml";
}
};
public abstract String getTitle();
public abstract String getFxmlFile();
String getStringFromResourceBundle(String key){
return ResourceBundle.getBundle("Bundle").getString(key);
}
}
java spring-boot fxml
add a comment |
I found the following error in springboot application. The error part in FXMLController.java is uploaded here. Also uploaded its necessary files. I'am trying to connect java and fxml file. Kindly help me. Thanks in advance
LibraryAutomationApplication.java
package com.alphabot.library;
import java.io.IOException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import javafx.application.Application;
import javafx.stage.Stage;
@SpringBootApplication
public class LibraryAutomationApplication extends Application {
protected ConfigurableApplicationContext springContext;
protected StageManager stageManager;
@Override
public void init() throws Exception {
springContext = springBootApplicationContext();
}
@Override
public void start(Stage stage) throws IOException {
stageManager = springContext.getBean(StageManager.class, stage);
//stage.setResizable(false);
//stage.setFullScreen(true);
showLoginView();
stage.setMinWidth(1000);
stage.setMinHeight(650);
}
private void showLoginView() throws IOException {
stageManager.switchScene(FxmlView.MAIN);
}
public static void main(final String args) {
launch(args);
}
@Override
public void stop() throws Exception {
springContext.close();
}
private ConfigurableApplicationContext springBootApplicationContext() {
SpringApplicationBuilder builder = new SpringApplicationBuilder(LibraryAutomationApplication.class);
String args = getParameters().getRaw().stream().toArray(String::new);
return builder.run(args);
}
}
AppJavaConfig.java
package com.alphabot.library.config;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ResourceBundle;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import com.alphabot.library.logging.ExceptionWriter;
@Configuration
public class AppJavaConfig {
@Autowired
SpringFXMLLoader springFXMLLoader;
@Bean
@Scope("prototype")
public ExceptionWriter exceptionWriter() {
return new ExceptionWriter(new StringWriter());
}
@Bean
public ResourceBundle resourceBundle() {
return ResourceBundle.getBundle("Bundle");
}
@Bean
@Lazy(value = true)
public StageManager stageManager(Stage stage) throws IOException {
return new StageManager(springFXMLLoader, stage);
}
}
SpringFXMLLoader.java
package com.alphabot.library.config;
import java.io.IOException;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@Component
public class SpringFXMLLoader {
private final ResourceBundle resourceBundle;
private final ApplicationContext context;
@Autowired
public SpringFXMLLoader(ApplicationContext context, ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
this.context = context;
}
public Parent load(String fxmlPath) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setControllerFactory(context::getBean);
loader.setResources(resourceBundle);
loader.setLocation(getClass().getResource(fxmlPath));
return loader.load();
}
}
StageManager.java
package com.alphabot.library.config;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Objects;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.alphabot.library.view.FxmlView;
import com.alphabot.library.config.StageManager;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class StageManager {
private static final Logger LOG = getLogger(StageManager.class);
private SpringFXMLLoader springFXMLLoader;
private final Stage primaryStage;
public StageManager(SpringFXMLLoader springFXMLLoader, Stage stage) {
this.springFXMLLoader = springFXMLLoader;
this.primaryStage = stage;
}
@Autowired
public Node switchScene(final FxmlView view) {
Parent viewRootNodeHierarchy = loadViewNodeHierarchy(view.getFxmlFile());
show(viewRootNodeHierarchy, view.getTitle());
return viewRootNodeHierarchy;
}
private void show(final Parent rootnode, String title) {
Scene scene = prepareScene(rootnode);
primaryStage.setTitle(title);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.centerOnScreen();
try {
primaryStage.show();
} catch (Exception exception) {
logAndExit ("Unable to show scene for title" + title, exception);
}
}
private Scene prepareScene(Parent rootnode){
Scene scene = primaryStage.getScene();
if (scene == null) {
scene = new Scene(rootnode);
}
scene.setRoot(rootnode);
return scene;
}
private Parent loadViewNodeHierarchy(String fxmlFilePath) {
Parent rootNode = null;
try {
rootNode = springFXMLLoader.load(fxmlFilePath);
Objects.requireNonNull(rootNode, "A Root FXML node must not be null");
} catch (Exception exception) {
logAndExit("Unable to load FXML view" + fxmlFilePath, exception);
}
return rootNode;
}
private void logAndExit(String errorMsg, Exception exception) {
LOG.error(errorMsg, exception, exception.getCause());
Platform.exit();
}
}
FXMLController.java
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@Component
public class FXMLController implements Initializable {
protected StageManager stageManager;
protected ConfigurableApplicationContext springContext;
@FXML
private StackPane mainPane;
@FXML
private JFXButton btnHome;
@FXML
private JFXButton btnAuthors;
@FXML
private JFXButton btnBooks;
@FXML
private JFXButton btnJournals;
@FXML
private JFXButton btnIssueReturn;
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void homeOnAction(ActionEvent event) {
Stage stage = (Stage) btnHome.getScene().getWindow();
stage.setTitle("Library Management- Home");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(showAuthorsView());
}
@Bean
private Node showAuthorsView() throws IOException {
stageManager = springContext.getBean(StageManager.class, mainPane);
return stageManager.switchScene(FxmlView.AUTHORS);
}
@FXML
private void booksOnAction(ActionEvent event) {
// Stage stage = (Stage) btnBooks.getScene().getWindow();
// stage.setTitle("Library Management- Books");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/BooksPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void journalsOnAction(ActionEvent event) {
Stage stage = (Stage) btnJournals.getScene().getWindow();
stage.setTitle("Library Management- Journals");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/JournalsPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void issueReturnOnAction(ActionEvent event) {
Stage stage = (Stage) btnIssueReturn.getScene().getWindow();
stage.setTitle("Library Management- Issue or Return");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/IssueReturnPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
ExceptionWriter.java
package com.alphabot.library.logging;
import java.io.PrintWriter;
import java.io.Writer;
public class ExceptionWriter extends PrintWriter {
public ExceptionWriter(Writer writer) {
super(writer);
}
private String wrapAroundWithNewlines(String stringWithoutNewlines) {
return ("n" + stringWithoutNewlines + "n");
}
public String getExceptionAsString(Throwable throwable) {
throwable.printStackTrace(this);
String exception = super.out.toString();
return (wrapAroundWithNewlines(exception));
}
}
FxmlView.java
package com.alphabot.library.view;
import java.util.ResourceBundle;
public enum FxmlView {
LOGIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/Login.fxml";
}
},
MAIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/MainPanel.fxml";
}
},
AUTHORS {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/AuthorsPanel.fxml";
}
},
FPASS {
@Override
public String getTitle() {
return getStringFromResourceBundle("forgotPassword.title");
}
@Override
public String getFxmlFile() {
return "/fxml/ForgotPassword.fxml";
}
};
public abstract String getTitle();
public abstract String getFxmlFile();
String getStringFromResourceBundle(String key){
return ResourceBundle.getBundle("Bundle").getString(key);
}
}
java spring-boot fxml
Could you add the logs?
– Jonathan Johx
Nov 28 '18 at 13:47
Jonathan Johx- Thank you for your interest to solve the issue. Actually I got the solution. The issue because of Annotation miss matching. Thank you very much
– Vishnu M S
Nov 28 '18 at 16:38
you're welcome. If you have the solution. it'd be nice that you post it :) kind regards.
– Jonathan Johx
Nov 28 '18 at 16:41
add a comment |
I found the following error in springboot application. The error part in FXMLController.java is uploaded here. Also uploaded its necessary files. I'am trying to connect java and fxml file. Kindly help me. Thanks in advance
LibraryAutomationApplication.java
package com.alphabot.library;
import java.io.IOException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import javafx.application.Application;
import javafx.stage.Stage;
@SpringBootApplication
public class LibraryAutomationApplication extends Application {
protected ConfigurableApplicationContext springContext;
protected StageManager stageManager;
@Override
public void init() throws Exception {
springContext = springBootApplicationContext();
}
@Override
public void start(Stage stage) throws IOException {
stageManager = springContext.getBean(StageManager.class, stage);
//stage.setResizable(false);
//stage.setFullScreen(true);
showLoginView();
stage.setMinWidth(1000);
stage.setMinHeight(650);
}
private void showLoginView() throws IOException {
stageManager.switchScene(FxmlView.MAIN);
}
public static void main(final String args) {
launch(args);
}
@Override
public void stop() throws Exception {
springContext.close();
}
private ConfigurableApplicationContext springBootApplicationContext() {
SpringApplicationBuilder builder = new SpringApplicationBuilder(LibraryAutomationApplication.class);
String args = getParameters().getRaw().stream().toArray(String::new);
return builder.run(args);
}
}
AppJavaConfig.java
package com.alphabot.library.config;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ResourceBundle;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import com.alphabot.library.logging.ExceptionWriter;
@Configuration
public class AppJavaConfig {
@Autowired
SpringFXMLLoader springFXMLLoader;
@Bean
@Scope("prototype")
public ExceptionWriter exceptionWriter() {
return new ExceptionWriter(new StringWriter());
}
@Bean
public ResourceBundle resourceBundle() {
return ResourceBundle.getBundle("Bundle");
}
@Bean
@Lazy(value = true)
public StageManager stageManager(Stage stage) throws IOException {
return new StageManager(springFXMLLoader, stage);
}
}
SpringFXMLLoader.java
package com.alphabot.library.config;
import java.io.IOException;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@Component
public class SpringFXMLLoader {
private final ResourceBundle resourceBundle;
private final ApplicationContext context;
@Autowired
public SpringFXMLLoader(ApplicationContext context, ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
this.context = context;
}
public Parent load(String fxmlPath) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setControllerFactory(context::getBean);
loader.setResources(resourceBundle);
loader.setLocation(getClass().getResource(fxmlPath));
return loader.load();
}
}
StageManager.java
package com.alphabot.library.config;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Objects;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.alphabot.library.view.FxmlView;
import com.alphabot.library.config.StageManager;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class StageManager {
private static final Logger LOG = getLogger(StageManager.class);
private SpringFXMLLoader springFXMLLoader;
private final Stage primaryStage;
public StageManager(SpringFXMLLoader springFXMLLoader, Stage stage) {
this.springFXMLLoader = springFXMLLoader;
this.primaryStage = stage;
}
@Autowired
public Node switchScene(final FxmlView view) {
Parent viewRootNodeHierarchy = loadViewNodeHierarchy(view.getFxmlFile());
show(viewRootNodeHierarchy, view.getTitle());
return viewRootNodeHierarchy;
}
private void show(final Parent rootnode, String title) {
Scene scene = prepareScene(rootnode);
primaryStage.setTitle(title);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.centerOnScreen();
try {
primaryStage.show();
} catch (Exception exception) {
logAndExit ("Unable to show scene for title" + title, exception);
}
}
private Scene prepareScene(Parent rootnode){
Scene scene = primaryStage.getScene();
if (scene == null) {
scene = new Scene(rootnode);
}
scene.setRoot(rootnode);
return scene;
}
private Parent loadViewNodeHierarchy(String fxmlFilePath) {
Parent rootNode = null;
try {
rootNode = springFXMLLoader.load(fxmlFilePath);
Objects.requireNonNull(rootNode, "A Root FXML node must not be null");
} catch (Exception exception) {
logAndExit("Unable to load FXML view" + fxmlFilePath, exception);
}
return rootNode;
}
private void logAndExit(String errorMsg, Exception exception) {
LOG.error(errorMsg, exception, exception.getCause());
Platform.exit();
}
}
FXMLController.java
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@Component
public class FXMLController implements Initializable {
protected StageManager stageManager;
protected ConfigurableApplicationContext springContext;
@FXML
private StackPane mainPane;
@FXML
private JFXButton btnHome;
@FXML
private JFXButton btnAuthors;
@FXML
private JFXButton btnBooks;
@FXML
private JFXButton btnJournals;
@FXML
private JFXButton btnIssueReturn;
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void homeOnAction(ActionEvent event) {
Stage stage = (Stage) btnHome.getScene().getWindow();
stage.setTitle("Library Management- Home");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(showAuthorsView());
}
@Bean
private Node showAuthorsView() throws IOException {
stageManager = springContext.getBean(StageManager.class, mainPane);
return stageManager.switchScene(FxmlView.AUTHORS);
}
@FXML
private void booksOnAction(ActionEvent event) {
// Stage stage = (Stage) btnBooks.getScene().getWindow();
// stage.setTitle("Library Management- Books");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/BooksPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void journalsOnAction(ActionEvent event) {
Stage stage = (Stage) btnJournals.getScene().getWindow();
stage.setTitle("Library Management- Journals");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/JournalsPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void issueReturnOnAction(ActionEvent event) {
Stage stage = (Stage) btnIssueReturn.getScene().getWindow();
stage.setTitle("Library Management- Issue or Return");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/IssueReturnPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
ExceptionWriter.java
package com.alphabot.library.logging;
import java.io.PrintWriter;
import java.io.Writer;
public class ExceptionWriter extends PrintWriter {
public ExceptionWriter(Writer writer) {
super(writer);
}
private String wrapAroundWithNewlines(String stringWithoutNewlines) {
return ("n" + stringWithoutNewlines + "n");
}
public String getExceptionAsString(Throwable throwable) {
throwable.printStackTrace(this);
String exception = super.out.toString();
return (wrapAroundWithNewlines(exception));
}
}
FxmlView.java
package com.alphabot.library.view;
import java.util.ResourceBundle;
public enum FxmlView {
LOGIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/Login.fxml";
}
},
MAIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/MainPanel.fxml";
}
},
AUTHORS {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/AuthorsPanel.fxml";
}
},
FPASS {
@Override
public String getTitle() {
return getStringFromResourceBundle("forgotPassword.title");
}
@Override
public String getFxmlFile() {
return "/fxml/ForgotPassword.fxml";
}
};
public abstract String getTitle();
public abstract String getFxmlFile();
String getStringFromResourceBundle(String key){
return ResourceBundle.getBundle("Bundle").getString(key);
}
}
java spring-boot fxml
I found the following error in springboot application. The error part in FXMLController.java is uploaded here. Also uploaded its necessary files. I'am trying to connect java and fxml file. Kindly help me. Thanks in advance
LibraryAutomationApplication.java
package com.alphabot.library;
import java.io.IOException;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import javafx.application.Application;
import javafx.stage.Stage;
@SpringBootApplication
public class LibraryAutomationApplication extends Application {
protected ConfigurableApplicationContext springContext;
protected StageManager stageManager;
@Override
public void init() throws Exception {
springContext = springBootApplicationContext();
}
@Override
public void start(Stage stage) throws IOException {
stageManager = springContext.getBean(StageManager.class, stage);
//stage.setResizable(false);
//stage.setFullScreen(true);
showLoginView();
stage.setMinWidth(1000);
stage.setMinHeight(650);
}
private void showLoginView() throws IOException {
stageManager.switchScene(FxmlView.MAIN);
}
public static void main(final String args) {
launch(args);
}
@Override
public void stop() throws Exception {
springContext.close();
}
private ConfigurableApplicationContext springBootApplicationContext() {
SpringApplicationBuilder builder = new SpringApplicationBuilder(LibraryAutomationApplication.class);
String args = getParameters().getRaw().stream().toArray(String::new);
return builder.run(args);
}
}
AppJavaConfig.java
package com.alphabot.library.config;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ResourceBundle;
import javafx.stage.Stage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import com.alphabot.library.logging.ExceptionWriter;
@Configuration
public class AppJavaConfig {
@Autowired
SpringFXMLLoader springFXMLLoader;
@Bean
@Scope("prototype")
public ExceptionWriter exceptionWriter() {
return new ExceptionWriter(new StringWriter());
}
@Bean
public ResourceBundle resourceBundle() {
return ResourceBundle.getBundle("Bundle");
}
@Bean
@Lazy(value = true)
public StageManager stageManager(Stage stage) throws IOException {
return new StageManager(springFXMLLoader, stage);
}
}
SpringFXMLLoader.java
package com.alphabot.library.config;
import java.io.IOException;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@Component
public class SpringFXMLLoader {
private final ResourceBundle resourceBundle;
private final ApplicationContext context;
@Autowired
public SpringFXMLLoader(ApplicationContext context, ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
this.context = context;
}
public Parent load(String fxmlPath) throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setControllerFactory(context::getBean);
loader.setResources(resourceBundle);
loader.setLocation(getClass().getResource(fxmlPath));
return loader.load();
}
}
StageManager.java
package com.alphabot.library.config;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Objects;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.alphabot.library.view.FxmlView;
import com.alphabot.library.config.StageManager;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class StageManager {
private static final Logger LOG = getLogger(StageManager.class);
private SpringFXMLLoader springFXMLLoader;
private final Stage primaryStage;
public StageManager(SpringFXMLLoader springFXMLLoader, Stage stage) {
this.springFXMLLoader = springFXMLLoader;
this.primaryStage = stage;
}
@Autowired
public Node switchScene(final FxmlView view) {
Parent viewRootNodeHierarchy = loadViewNodeHierarchy(view.getFxmlFile());
show(viewRootNodeHierarchy, view.getTitle());
return viewRootNodeHierarchy;
}
private void show(final Parent rootnode, String title) {
Scene scene = prepareScene(rootnode);
primaryStage.setTitle(title);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
primaryStage.centerOnScreen();
try {
primaryStage.show();
} catch (Exception exception) {
logAndExit ("Unable to show scene for title" + title, exception);
}
}
private Scene prepareScene(Parent rootnode){
Scene scene = primaryStage.getScene();
if (scene == null) {
scene = new Scene(rootnode);
}
scene.setRoot(rootnode);
return scene;
}
private Parent loadViewNodeHierarchy(String fxmlFilePath) {
Parent rootNode = null;
try {
rootNode = springFXMLLoader.load(fxmlFilePath);
Objects.requireNonNull(rootNode, "A Root FXML node must not be null");
} catch (Exception exception) {
logAndExit("Unable to load FXML view" + fxmlFilePath, exception);
}
return rootNode;
}
private void logAndExit(String errorMsg, Exception exception) {
LOG.error(errorMsg, exception, exception.getCause());
Platform.exit();
}
}
FXMLController.java
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.FxmlView;
import com.jfoenix.controls.JFXButton;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@Component
public class FXMLController implements Initializable {
protected StageManager stageManager;
protected ConfigurableApplicationContext springContext;
@FXML
private StackPane mainPane;
@FXML
private JFXButton btnHome;
@FXML
private JFXButton btnAuthors;
@FXML
private JFXButton btnBooks;
@FXML
private JFXButton btnJournals;
@FXML
private JFXButton btnIssueReturn;
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void homeOnAction(ActionEvent event) {
Stage stage = (Stage) btnHome.getScene().getWindow();
stage.setTitle("Library Management- Home");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/HomePanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(showAuthorsView());
}
@Bean
private Node showAuthorsView() throws IOException {
stageManager = springContext.getBean(StageManager.class, mainPane);
return stageManager.switchScene(FxmlView.AUTHORS);
}
@FXML
private void booksOnAction(ActionEvent event) {
// Stage stage = (Stage) btnBooks.getScene().getWindow();
// stage.setTitle("Library Management- Books");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/BooksPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void journalsOnAction(ActionEvent event) {
Stage stage = (Stage) btnJournals.getScene().getWindow();
stage.setTitle("Library Management- Journals");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/JournalsPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void issueReturnOnAction(ActionEvent event) {
Stage stage = (Stage) btnIssueReturn.getScene().getWindow();
stage.setTitle("Library Management- Issue or Return");
try {
mainPane.getChildren().clear();
mainPane.getChildren().add(FXMLLoader.load(getClass().getResource("/fxml/IssueReturnPanel.fxml")));
} catch (IOException ex) {
Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
ExceptionWriter.java
package com.alphabot.library.logging;
import java.io.PrintWriter;
import java.io.Writer;
public class ExceptionWriter extends PrintWriter {
public ExceptionWriter(Writer writer) {
super(writer);
}
private String wrapAroundWithNewlines(String stringWithoutNewlines) {
return ("n" + stringWithoutNewlines + "n");
}
public String getExceptionAsString(Throwable throwable) {
throwable.printStackTrace(this);
String exception = super.out.toString();
return (wrapAroundWithNewlines(exception));
}
}
FxmlView.java
package com.alphabot.library.view;
import java.util.ResourceBundle;
public enum FxmlView {
LOGIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/Login.fxml";
}
},
MAIN {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/MainPanel.fxml";
}
},
AUTHORS {
@Override
public String getTitle() {
return getStringFromResourceBundle("login.title");
}
@Override
public String getFxmlFile() {
return "/fxml/AuthorsPanel.fxml";
}
},
FPASS {
@Override
public String getTitle() {
return getStringFromResourceBundle("forgotPassword.title");
}
@Override
public String getFxmlFile() {
return "/fxml/ForgotPassword.fxml";
}
};
public abstract String getTitle();
public abstract String getFxmlFile();
String getStringFromResourceBundle(String key){
return ResourceBundle.getBundle("Bundle").getString(key);
}
}
java spring-boot fxml
java spring-boot fxml
edited Nov 28 '18 at 13:16
Vishnu M S
asked Nov 28 '18 at 11:03
Vishnu M SVishnu M S
13
13
Could you add the logs?
– Jonathan Johx
Nov 28 '18 at 13:47
Jonathan Johx- Thank you for your interest to solve the issue. Actually I got the solution. The issue because of Annotation miss matching. Thank you very much
– Vishnu M S
Nov 28 '18 at 16:38
you're welcome. If you have the solution. it'd be nice that you post it :) kind regards.
– Jonathan Johx
Nov 28 '18 at 16:41
add a comment |
Could you add the logs?
– Jonathan Johx
Nov 28 '18 at 13:47
Jonathan Johx- Thank you for your interest to solve the issue. Actually I got the solution. The issue because of Annotation miss matching. Thank you very much
– Vishnu M S
Nov 28 '18 at 16:38
you're welcome. If you have the solution. it'd be nice that you post it :) kind regards.
– Jonathan Johx
Nov 28 '18 at 16:41
Could you add the logs?
– Jonathan Johx
Nov 28 '18 at 13:47
Could you add the logs?
– Jonathan Johx
Nov 28 '18 at 13:47
Jonathan Johx- Thank you for your interest to solve the issue. Actually I got the solution. The issue because of Annotation miss matching. Thank you very much
– Vishnu M S
Nov 28 '18 at 16:38
Jonathan Johx- Thank you for your interest to solve the issue. Actually I got the solution. The issue because of Annotation miss matching. Thank you very much
– Vishnu M S
Nov 28 '18 at 16:38
you're welcome. If you have the solution. it'd be nice that you post it :) kind regards.
– Jonathan Johx
Nov 28 '18 at 16:41
you're welcome. If you have the solution. it'd be nice that you post it :) kind regards.
– Jonathan Johx
Nov 28 '18 at 16:41
add a comment |
1 Answer
1
active
oldest
votes
I changed FXMLController.java like this
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.*;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
@Component
public class FXMLController implements Initializable {
@FXML
private StackPane mainPane;
protected Node home, authors, books, journals, issue_return;
@Lazy
@Autowired
private StageManager stageManager;
@Override
public void initialize(URL location, ResourceBundle resources) {
mainPane.getChildren().clear();
mainPane.getChildren().add(stageManager.switchScene(FxmlView.HOME));
home = stageManager.switchScene(FxmlView.HOME);
authors = stageManager.switchScene(FxmlView.AUTHORS);
books = stageManager.switchScene(FxmlView.BOOKS);
journals = stageManager.switchScene(FxmlView.JOURNALS);
issue_return = stageManager.switchScene(FxmlView.ISSUE_RETURN);
}
@FXML
private void homeOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(home);
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(authors);
}
@FXML
private void booksOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(books);
}
@FXML
private void journalsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(journals);
}
@FXML
private void issueReturnOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(issue_return);
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53517952%2fspringbootorg-springframework-beans-factory-beancreationexception-error-creati%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I changed FXMLController.java like this
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.*;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
@Component
public class FXMLController implements Initializable {
@FXML
private StackPane mainPane;
protected Node home, authors, books, journals, issue_return;
@Lazy
@Autowired
private StageManager stageManager;
@Override
public void initialize(URL location, ResourceBundle resources) {
mainPane.getChildren().clear();
mainPane.getChildren().add(stageManager.switchScene(FxmlView.HOME));
home = stageManager.switchScene(FxmlView.HOME);
authors = stageManager.switchScene(FxmlView.AUTHORS);
books = stageManager.switchScene(FxmlView.BOOKS);
journals = stageManager.switchScene(FxmlView.JOURNALS);
issue_return = stageManager.switchScene(FxmlView.ISSUE_RETURN);
}
@FXML
private void homeOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(home);
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(authors);
}
@FXML
private void booksOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(books);
}
@FXML
private void journalsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(journals);
}
@FXML
private void issueReturnOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(issue_return);
}
}
add a comment |
I changed FXMLController.java like this
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.*;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
@Component
public class FXMLController implements Initializable {
@FXML
private StackPane mainPane;
protected Node home, authors, books, journals, issue_return;
@Lazy
@Autowired
private StageManager stageManager;
@Override
public void initialize(URL location, ResourceBundle resources) {
mainPane.getChildren().clear();
mainPane.getChildren().add(stageManager.switchScene(FxmlView.HOME));
home = stageManager.switchScene(FxmlView.HOME);
authors = stageManager.switchScene(FxmlView.AUTHORS);
books = stageManager.switchScene(FxmlView.BOOKS);
journals = stageManager.switchScene(FxmlView.JOURNALS);
issue_return = stageManager.switchScene(FxmlView.ISSUE_RETURN);
}
@FXML
private void homeOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(home);
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(authors);
}
@FXML
private void booksOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(books);
}
@FXML
private void journalsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(journals);
}
@FXML
private void issueReturnOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(issue_return);
}
}
add a comment |
I changed FXMLController.java like this
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.*;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
@Component
public class FXMLController implements Initializable {
@FXML
private StackPane mainPane;
protected Node home, authors, books, journals, issue_return;
@Lazy
@Autowired
private StageManager stageManager;
@Override
public void initialize(URL location, ResourceBundle resources) {
mainPane.getChildren().clear();
mainPane.getChildren().add(stageManager.switchScene(FxmlView.HOME));
home = stageManager.switchScene(FxmlView.HOME);
authors = stageManager.switchScene(FxmlView.AUTHORS);
books = stageManager.switchScene(FxmlView.BOOKS);
journals = stageManager.switchScene(FxmlView.JOURNALS);
issue_return = stageManager.switchScene(FxmlView.ISSUE_RETURN);
}
@FXML
private void homeOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(home);
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(authors);
}
@FXML
private void booksOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(books);
}
@FXML
private void journalsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(journals);
}
@FXML
private void issueReturnOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(issue_return);
}
}
I changed FXMLController.java like this
package com.alphabot.library.controller;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import com.alphabot.library.config.StageManager;
import com.alphabot.library.view.*;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
@Component
public class FXMLController implements Initializable {
@FXML
private StackPane mainPane;
protected Node home, authors, books, journals, issue_return;
@Lazy
@Autowired
private StageManager stageManager;
@Override
public void initialize(URL location, ResourceBundle resources) {
mainPane.getChildren().clear();
mainPane.getChildren().add(stageManager.switchScene(FxmlView.HOME));
home = stageManager.switchScene(FxmlView.HOME);
authors = stageManager.switchScene(FxmlView.AUTHORS);
books = stageManager.switchScene(FxmlView.BOOKS);
journals = stageManager.switchScene(FxmlView.JOURNALS);
issue_return = stageManager.switchScene(FxmlView.ISSUE_RETURN);
}
@FXML
private void homeOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(home);
}
@FXML
private void authorsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(authors);
}
@FXML
private void booksOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(books);
}
@FXML
private void journalsOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(journals);
}
@FXML
private void issueReturnOnAction(ActionEvent event) throws IOException {
mainPane.getChildren().clear();
mainPane.getChildren().add(issue_return);
}
}
answered Nov 28 '18 at 19:10
Vishnu M SVishnu M S
13
13
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53517952%2fspringbootorg-springframework-beans-factory-beancreationexception-error-creati%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you add the logs?
– Jonathan Johx
Nov 28 '18 at 13:47
Jonathan Johx- Thank you for your interest to solve the issue. Actually I got the solution. The issue because of Annotation miss matching. Thank you very much
– Vishnu M S
Nov 28 '18 at 16:38
you're welcome. If you have the solution. it'd be nice that you post it :) kind regards.
– Jonathan Johx
Nov 28 '18 at 16:41