我试图运行下面的代码,源代码中提到的类已经定义除了authenticateUser,在突出显示的行错误消息“返回类型与 RequestHandler<Object,String>.handleRequest(Object, Context) 不兼容”是显示在下面加粗的代码行中。
请建议如何纠正这个问题。我正在尝试使用https://aws.amazon.com/blogs/developer/building-a-serverless-developer-authentication-api-in-java-using-aws-lambda-amazon-dynamodb-开发一个简单的用户身份验证系统和-amazon-cognito-part-1/作为参考。
package aws.java.lambda.demo;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
public class Authenticate_User implements RequestHandler<Object, String> {
@Override
ERROR FACE-->public AuthenticateUserResponse handleRequest(Object input, Context context)<--ERROR FACED {
AuthenticateUserResponse authenticateUserResponse = new AuthenticateUserResponse();
@SuppressWarnings("unchecked")
LinkedHashMap inputHashMap = (LinkedHashMap)input;
User user = authenticateUser(inputHashMap);
if(user!=null){
authenticateUserResponse.setUserId(user.getUserId());
authenticateUserResponse.setStatus("true");
authenticateUserResponse.setOpenIdToken(user.getOpenIdToken());
}else{
authenticateUserResponse.setUserId(null);
authenticateUserResponse.setStatus("false");
authenticateUserResponse.setOpenIdToken(null);
}
return authenticateUserResponse;
}
}