Dependency injection connects an abstraction to a concrete implementation at runtime. In a hexagonal system, the assembly module uses Spring Boot to discover beans, match interfaces to implementations, and inject dependencies. section 6.2
Keep framework wiring in the assembly module, not the application core. For construction that needs an external service, use a standalone factory and inject that service so the factory remains testable with mocks. section 6.2 section 3.6
Listing 3.14 Using factories for complex construction of entities
public class ArticleFactory { #A
private final ArticleIdGenerator idGenerator;
public ArticleFactory(final ArticleIdGenerator idGenerator) {
this.idGenerator = idGenerator; #B
}
public Validation<Seq<DomainError>, Article> create( #C
final Title title, final Content content, final AuthorId authorId) {
final ArticleId id = this.idGenerator.next(); #D
return Article.validateThenCreate(id, title, content, authorId);
} #E
}
ArticleFactory receives an ArticleIdGenerator through its constructor and uses it to create an article. section 3.6



























