An opinionated view on how to do dependency injection and FXML view handling in JavaFX.
Complementary Blog Posts:
Supportive tooling for using JavaFX together with dependency injection frameworks such as Spring or CDI
Declarative FXML view binding - Create a controller class and annotate it with
handle view loading and instantiating
attribute in FXML, with controller classes being instantiated, autowired and fully managed by your DI framework of choice
Acquire managed controller instances with automatically weaved FXML views
Support for tiling / componentisation: Create view components with independent controllers and aggregate them in other views using
, again with full DI support
SceneBuilder fully supported, even when creating and using view tiles
Spring and Spring Boot specific:
Add the Spring Boot Starter dependency to your project and you are all set:
<dependency> <groupId>net.rgielen</groupId> <artifactId>javafx-weaver-spring-boot-starter</artifactId> <version>1.3.0</version> </dependency>
`javafx-weaver-spring`as a dependency to your project.
<dependency> <groupId>net.rgielen</groupId> <artifactId>javafx-weaver-core</artifactId> <version>1.3.0</version> </dependency>
For now, refer to the JavaDocs and the Spring Boot based FxWeaver Sample and Feature Demo Project.
More documentation to come.
The project is licensed under Apache License V2.0.
Feel free to open issues and pull requests on GitHub. This is a side project of mine, so please don’t expect enterprise grade support.
You can find me on Twitter as well: @rgielen