我有 Scala 特质
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 的公共构造函数或伴随对象