
"If you're coming from Java and Spring, this reaction is normal. Scala does things differently. There's no runtime scanning, no hidden wiring, and no @Autowired. Instead, Scala uses type-driven dependency injection - and it's all checked at compile time. In this article, we'll break down given and using, map them to Java concepts you already know, and show why Scala DI feels explicit but safe."
"Scala 3 introduced given and using to handle implicit dependencies in a clean, type-safe way. Think of it as declaring a service and then asking for it, but without Spring annotations or runtime container magic."
"Breakdown: given PaymentService with ... → defines an implementation (like a Spring bean). using paymentService: PaymentService → requests a dependency (like @Autowired ) The compiler automatically wires the given instance when creating OrderService. Notice: nothing happens at runtime magically. Scala's compiler resolves it."
Scala 3 introduced given and using to provide type-driven dependency injection that is resolved at compile time. given declares an implementation and using requests a dependency; the compiler wires implementations during compilation rather than at runtime. There is no container scanning, no runtime reflection, and no hidden wiring or @Autowired annotations. Missing dependencies produce compile errors instead of runtime failures. Examples show given defining a PaymentService implementation, using requesting it in a constructor, and summon retrieving an instance, demonstrating explicit, type-checked dependency wiring.
Read at Medium
Unable to calculate read time
Collection
[
|
...
]