Tôi có một giao diện java tạo ra có chứa một phương pháp:Chuyển đổi scala trong tương lai để tương lai java
public Future<?> getCustomersAsync(AsyncHandler<Customer> asyncHandler);
tôi muốn thực hiện nó bằng cách sử Akka. Tôi đã viết như sau:
override def getCustomerAsync(asyncHandler: AsyncHandler[Customer]): Future[_] = {
myActorRef.ask(GetCustomer, system.actorOf(Props[Responder]))
}
Vấn đề là ask
lợi nhuận scala.concurrent.Future[Any]
và phương pháp phải trả lại 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]))
^
Làm cách nào để chuyển đổi này?