Auto-Configuration¶
Spring JavaFX Boot uses Spring Boot's auto-configuration mechanism to register all framework beans automatically when JavaFX is on the classpath.
Activation¶
The auto-configuration is activated by SpringJavaFxAutoConfiguration, which is triggered by:
This means all beans are registered only when JavaFX is present on the classpath.
Registered Beans¶
| Bean | Type | Purpose |
|---|---|---|
localizedMessageSource |
LocalizedMessageSource |
Convenience wrapper for locale-aware i18n access |
fxViewResolver |
ViewResolver |
Resolves view names to FXML templates |
fxRouteRegistry |
FxRouteRegistry |
Scans @FxRoutes beans and builds the route table |
fxTitleService |
FxTitleService |
Manages the primary window title |
fxRouter |
FxRouter |
Central routing service |
Overriding Beans¶
Every auto-configured bean uses @ConditionalOnMissingBean. To replace any component, define your own @Bean of the same type:
@Configuration
public class CustomConfig {
@Bean
public ViewResolver fxViewResolver(MessageSource messageSource) {
// Custom view resolver with different prefix
return new ViewResolver(messageSource, "/views/", ".fxml");
}
}
The auto-configuration will skip registering fxViewResolver since yours already exists.
Bean Dependencies¶
FxRouter
├── FxRouteRegistry ← ApplicationContext
├── ViewResolver ← MessageSource, prefix, suffix
├── ApplicationContext
└── FxTitleService ← LocalizedMessageSource ← MessageSource
Initialization Order¶
- Spring context starts — auto-configuration registers all beans
FxRouteRegistry.@PostConstruct— scans for@FxRoutesbeans, registers all@FxMappingmethods, validates parent references, logs the route tableApplication.start()— your code callsrouter.setRootPane()androuter.navigateTo()to begin navigation
Required initialization
You must call router.setRootPane(rootPane) in Application.start() before any navigation. The router throws a RoutingException if this is not done.