【发布时间】:2015-11-12 17:45:54
【问题描述】:
我有如下界面:
trait Subject[T] {
def fetch() :Future[Option[T]]
}
和类:
class ChildSubject@Inject()(dao:Dao) extends Subject[String]{
def fetch(): Future[Option[String]] ={
dao.find("10").map{ name => Some(name)
}
}
还有一个模块:
class SubjectModule extends AbstractModule with ScalaModule{
override def configure(): Unit = {
val subMulti = ScalaMultibinder.newSetBinder[Subject](binder)
subMulti.addBinding.to[ChildSubject]
}
}
我尝试注入这个 Set:
@Singleton
class SomeClass @Inject()(subjects: Set[Subject]){
subjects.map{
//do somthing
}
}
我收到以下错误:
play.sbt.PlayExceptions$CompilationException: Compilation error[kinds
of the type arguments (com.test.Subject) do not conform to the expected
kinds of the type parameters (type T).
com.test.Subject's type parameters do not match type T's expected
parameters:
trait Subject has one type parameter, but type T has none]
有什么想法吗?? 谢谢!
【问题讨论】:
标签: scala playframework playframework-2.0 guice