scala - Error trying to inject a dependency in Lagom -
i'm trying create simple service send emails using lagom framework , scaladsl. i'm trying use play mailer plugin handle emails i'm struggling trying inject service implementation.
i created service trait , implementation passing mailerclient
dependency in constructor.
trait mailerservice extends service { ... } class mailerserviceimpl(mailerclient: mailerclient, persistententityregistry: persistententityregistry) extends mailerservice { ... }
i'm wiring service in applicationloader, following pattern explained in lagom documentation , in hello world application using macwire.
abstract class mailerapplication(context: lagomapplicationcontext) extends lagomapplication(context) cassandrapersistencecomponents ahcwscomponents { override lazy val lagomserver: lagomserver = serverfor[mailerservice](wire[mailerserviceimpl]) override lazy val jsonserializerregistry = mailerserializerregistry persistententityregistry.register(wire[mailentity]) }
when try compile, following error.
[error] /.../workspace/mailer/mailer-impl/src/main/scala/com/example/mailer/impl/mailerapplicationloader.scala:92: cannot find value of type: [play.api.libs.mailer.mailerclient]
i thought macwire able sort out dependencies constructor looks it's not really. i've tried different options, trying wire explicitly in application loader without success far.
i'm pretty sure there's i'm getting wrong how di works in lagom cannot figure out.
any ideas?
for mailerclient
injectable, need mix in mailercomponents
trait along other traits use in service.
for example:
// ... import play.api.libs.mailer._ abstract class mailerapplication(context: lagomapplicationcontext) extends lagomapplication(context) mailercomponents // add here cassandrapersistencecomponents ahcwscomponents { override lazy val lagomserver: lagomserver = serverfor[mailerservice](wire[mailerserviceimpl]) override lazy val jsonserializerregistry = mailerserializerregistry persistententityregistry.register(wire[mailentity]) }
this described in play mailer documentation on compile-time injection
Comments
Post a Comment