0
注入特质我有一个Scala的特质如何使用macwire
trait UserRepository {
def findByEmail(email: String): User
}
我想注入到这个服务与MacWire
class AccountService(){
val userRepo = wire[UserRepository]
}
,然后在测试或
类使用class AccountServiceSpec {
val userRepo = new UserRepositoryImpl()
val accountSvc = new AccountService() //<--not manually injecting repo in service constructor
}
,但我在服务类获得一个编译错误
找不到一个公共的构造函数,也不是 accounts.repository.UserRepository
谢谢,这就是我一直在寻找的。 – decapo