将 scala future 转换为 java future
2022-09-03 02:29:33
我有一个生成的java接口,其中包含一个方法:
public Future<?> getCustomersAsync(AsyncHandler<Customer> asyncHandler);
我想使用Akka实现它。我写了以下内容:
override def getCustomerAsync(asyncHandler: AsyncHandler[Customer]): Future[_] = {
myActorRef.ask(GetCustomer, system.actorOf(Props[Responder]))
}
问题是返回,并且该方法必须返回:ask
scala.concurrent.Future[Any]
java.util.concurrent.Future[?]
Error:(33, 17) type mismatch;
found : scala.concurrent.Future[Any]
required: java.util.concurrent.Future[?]
myActorRef.ask(GetCustomer, system.actorOf(Props[Responder]))
^
如何进行此转换?