Scala Play 2.8 - SwaggerPluggin Failing - com.google.inject.CreationException: Unable to create injector

40 Views Asked by At

I am using jackson module(com.fasterxml.jackson.module:jackson-module-scala_2.13:$jacksonVersion) 2.13.1 with play version 2.8.20. However getting this error:

controllers.SoftwareListControllerSpec > classMethod FAILED
    com.google.inject.CreationException: Unable to create injector, see the following errors:

    1) No implementation for play.modules.swagger.SwaggerPlugin was bound.
      while locating play.modules.swagger.SwaggerPlugin
        for the 2nd parameter of controllers.ApiHelpController.<init>(ApiHelpController.scala:64)
      while locating com.google.inject.Provider<controllers.ApiHelpController>
        for the 7th parameter of router.Routes.<init>(Routes.scala:48)
      at play.api.inject.RoutesProvider$.bindingsFromConfiguration(BuiltinModule.scala:139):
    Binding(class router.Routes to self) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)

Does anyone know how to fix this?

1

There are 1 best solutions below

0
Shivam Sahil On

During the time of initialization, while trying to configure the project, I needed to inject the dependency as shown below:

bind(classOf[SwaggerPlugin]).to(classOf[SwaggerPluginImpl]).asEagerSingleton()

Where the above two classes come from:

import play.modules.swagger.{SwaggerPlugin, SwaggerPluginImpl}