How to override binding in BuiltinModule

I’m attempting to override the default ActionBuilder.

With compile time DI I can do this in a custom application loader

override lazy val defaultActionBuilder = ...

With runtime DI, I am attempting to do this in a Module via

bind[DefaultActionBuilder].toProvider[...]

but I get

A binding to play.api.mvc.DefaultActionBuilder was already configured at play.api.inject.BuiltinModule$$anonfun$$lessinit$greater$1.apply(BuiltinModule.scala:59)

Is there any way around this?

jeff

1 Like

Hi @jsw,

You can extend GuiceApplicationLoader and overrides some bindings:

class MyGuiceAppLoader extends GuiceApplicationLoader {

  protected override def overrides(context: ApplicationLoader.Context): Seq[GuiceableModule] = {
    super.overrides(context) :+ (bind[DefaultActionBuilder].toProvider[...]: GuiceableModule)
  }

}

See more details here.

Best.

3 Likes