这可能是一个愚蠢的问题,但我需要知道。我有一个界面
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsync;
public interface AsyncClient extends AmazonDynamoDBAsync{
}
我有一个具有方法的ClientCreator类
import com.company.clients.AsyncClient;
public class ClientCreator {
public static AsyncClient getAsyncClient() throws FileNotFoundException, IllegalArgumentException, IOException{
AmazonDynamoDBAsync client = new AmazonDynamoDBAsyncClient(getCredentials());
client.setRegion(getRegion());
return (AsyncClient)client;
}
.
.
.
这里AmazonDynamoDBAsyncClient 实现了 AmazonDynamoDBAsync和AsyncClient 扩展了 AmazonDynamoDBAsync,但是这段代码不起作用并抛出
com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClient 无法转换为 com.company.clients.AsyncClient
但为什么?