Your code is correct. Additionally to that, you need to configure a module in your application.conf

play.modules.enabled += "com.example.HelloModule"

And then in this very Module you need to describe your dependency injected classes:

import play.api.inject._

class HelloModule extends Module {
  def bindings(environment: Environment,
               configuration: Configuration) = Seq(

For the offical documentation see this link.


You may need to prepend val to the parameters:

class ExampleController @Inject() (val serviceOne: ServiceOne, val serviceTwo: ServiceTwo) extends Controller {

And also check that you have the correct import:

import javax.inject.Inject

Here you also can find an example with multiple dependencies, maybe it helps.

Related Query

More Query from same tag