How would one do dependency injection in scala?

A new dependency injection library specifically for Scala is Dick Wall's SubCut.

Whereas the Jonas Bonér article referenced in Dan Story's answer emphasizes compile-time bound instances and static injection (via mix-ins), SubCut is based on runtime initialization of immutable modules, and dynamic injection by querying the bound modules by type, string names, or scala.Symbol names.

You can read more about the comparison with the Cake pattern in the GettingStarted document.


Standard Java DI frameworks will usually work with Scala, but you can also use language constructs to achieve the same effect without external dependencies.