I know that the best way to handle dependency injection in Scala is to use tools that were created specifically for the language, but I'm working on a project that needs to integrate some Scala and Java code.
Then I use Google Guice, which implements the JSR-330 specification. Fortunately, during the integration of Guice and Scala, I did not find any problems. I use constructor injection because I have to deal with immutability.
My question is: why in Scala should we use the notation @Inject()before the constructor parameter? Why parathesis ()? The following is an example:
class MyClass @Inject() (val another: AnotherClass) {
}
source
share