Listing every bean in a composition root is avoidable: component scanning discovers eligible classes and registers them with Spring. In a hexagonal design, the assembly layer configures discovery while the application core remains independent of Spring. section 6.2.2 section 9.6.2
The assembly module can scan a base package and add annotation filters for architectural stereotypes such as @ApplicationService, @Adapter, and @DomainService. Scanning discovers candidates and resolves implementations; constructor dependencies remain explicitly declared. It does not enforce framework boundaries—architecture tests do that. section 6.2.2 section 9.6.2
Listing 6.4 ApplicationAssembler with annotation-based component scanning
@Configuration
@ComponentScan(
basePackages = "com.writeflow",
includeFilters = @ComponentScan.Filter( #A
type = FilterType.ANNOTATION,
classes = {
ApplicationService.class, #B
Adapter.class,
DomainService.class
}
)
)
class ApplicationAssembler {
}
Shows an assembly configuration that scans a package and registers classes marked with architectural annotations. section 6.2.2

