score:16
Accepted answer
I think the simplest approach would be to declare the authService in your trait but keep it abstract, then have the controller which extends it handle the injection (I believe this is how MessagesApi/I18nSupport
injection works). So you could do:
trait Secured {
val authService: AuthService
...
}
controller Application @Inject()(override val authService: AuthService) extends Controller with Secured {
...
}
Source: stackoverflow.com
Related Query
- In Play 2.4 with DI, how to use a service class in "Secured" trait?
- How to use circe with generic case class that extends a sealed trait
- How to inject a service class into a Spec class with Play framework
- How to use IntelliJ with Play Framework and Scala
- How to use scala trait with `self` reference?
- How to use stackable trait pattern with Akka actors?
- How to instantiate trait which extends class with constructor
- Scala How to use extends with an anonymous class
- How to use Joda DateTime with Play Json
- Best way to use type classes with list parametrized with some base class, abstract class or trait
- How to write a Play JSON writes converter for a case class with a single nullable member
- Scala spark: how to use dataset for a case class with the schema has snake_case?
- How to use play-plugins-mailer with Play 2.3 and Scala 2.11?
- How to use the Play Framework with Google App Engine with locally installed Java 7?
- How to implement a trait with a generic case class that creates a dataset in Scala
- How to write first class functions with context bounds, that can be called cleanly at use site?
- How to use OutputStreams with chunked response in Play 2.1
- How to use SORM framework with Play Framework?
- How do you use scalamock to mock a class with constructor parameters
- how plugin works with inject and object instead of class in play 2.4
- Can we use Google Guice DI with a Scala Object instead of a Scala class in Play 2.4 with scala
- How to convert a json with a single value to a case class using play json
- How to determine to use trait to 'with' or class to 'inject'?
- How to bind a class that extends a Trait with a monadic type parameter using Scala Guice?
- How to write a symmetric Play Json formatter for a case class with one field in scala?
- How to use a Filtered Service with RoutingService in Finagle
- how can i use lift-mongo-record with play framework?
- How to serialise and deserialise a recursive sealed trait with Play Json?
- Decorating a Scala Play Controller with Java class Secured extends Security.Authenticator
- How can I use Json.reads to deserialize JSON into a case class with optional constructor parameters
More Query from same tag
- How to pass a CaseWhen variable as a parameter in Scala
- flatMap function in scala
- Is it possible to add a method to a built-in type in Scala?
- Definition of implicit environment value in example play-silhouette template (using Guice)
- How to call Await.ready for function returning EitherT[Future,Failure,Result]
- How to update an observable manually?
- Iterate through JSON in Scala
- Akka persistence with confirmed delivery gives inconsistent results
- Scala Constructor Confusion - please clarify
- sbt corrupts terminal display
- Why is my map() not working?
- Spark Hbase connector (SHC) is not returning any data from HBase table
- Expressing type inequality conditions in a simple bound
- How to solve Scala compiler's "class X inherits different type instances of class Y[Z]" error?
- Unable to run integration test in Intellij Idea for scala project
- How to add a deadline to a future in Scala?
- Scala: if inside match case
- Scala compilation error (s"")
- Scala, cats - how to create tagless-final implementation with IO (or other monad) and Either?
- Path Dependent Types: Idris to Scala
- use type parameter for create subclass in scala language
- spark join function error
- Scala worksheet can not resolve class name - IntelliJ IDEA
- Scala, repeat a finite list infinitely
- Sbt multi-module build - maintain module dep graph as libraryDependencies in modules
- Scala Slick: Query using direct embedding doesn't work
- Feature toggle for scala
- Merge repeated values into a field in a Dataframe with scala and spark
- How to exclude unmanaged resources from Compile scope only (not from Test)
- Scala: Calculating the Moving Sum of a List with a fixed window