An opinionated view on how to do dependency injection and FXML view handling in JavaFX.
Complementary Blog Posts:
Features:
-
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
and let@FxmlView
handle view loading and instantiatingFxWeaver
-
Support for
attribute in FXML, with controller classes being instantiated, autowired and fully managed by your DI framework of choicefx:controller
-
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 supportfx:include
-
SceneBuilder fully supported, even when creating and using view tiles
-
Spring and Spring Boot specific:
-
Support for direct injection of
instances based on generic typesFxControllerAndView
-
Spring Boot Starter including auto-configuration
-
Add the Spring Boot Starter dependency to your project and you are all set:
with Maven:
<dependency>
<groupId>net.rgielen</groupId>
<artifactId>javafx-weaver-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
with Gradle:
implementation 'net.rgielen:javafx-weaver-spring-boot-starter:2.0.0'
Add
or javafx-weaver-core
`javafx-weaver-spring
`as a dependency to your project.
with Maven:
<dependency>
<groupId>net.rgielen</groupId>
<artifactId>javafx-weaver-core</artifactId>
<version>2.0.0</version>
</dependency>
with Gradle:
implementation 'javafx-weaver-spring-boot-starter:1.3.0'
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