Hey so I downloaed all the tools for AWS toolkit required for eclipse, and new im trying to create A new AWS lambda project and I give it a package, project name and change input type to custom then provide String for input type and out Type, after loading it creates a project but comes back with errors so, please can some tell my what's wrong??
package com.amazonaws.lambda.demo;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
public class LambdaFunctionHandler implements RequestHandler<String, String> {
@Override
public String handleRequest(String input, Context context) // error is this hanleRequest it states Multiple markers at this line
- The method handleRequest(String, Context) of type LambdaFunctionHandler must override a superclass method
- implements {
context.getLogger().log("Input: " + input);
// TODO: implement your handler
return null;
}
}
}
The AWS documentation is outdated.
You need to implement a different interface.
Passing a map:
public class MyHandler implements RequestHandler<Map<String,Object>,String>
Passing into a custom POJO object:
public class MyHandler implements RequestHandler<CustomRequest,CustomResponse> {
Consuming a stream:
public class MyHandler implements RequestStreamHandler {
Make sure to grab the right dependency:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
I developed a sample application implementing each of the interfaces. You can just clone it from github . One of the handlers will print out all available environment variables as well.
Lambda expects JSON as input.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.