每次我使用本指南在 Eclipse 中创建新的 AWS Lambda Java 项目时,都会出现以下编译错误。
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
public class MyHandler implements RequestHandler<Object, Object> {
@Override
public Object handleRequest(Object input, Context context) {
context.getLogger().log("Input: " + input);
// TODO: implement your handler
return null;
}
}
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject</groupId>
<artifactId>myfirstlambda</artifactId>
<version>4.0.0</version>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.127</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
我有其他项目以前由我的同事创建,它们似乎具有完全相同的结构,并且它们在我的 eclipse 上工作得非常好。当我尝试匹配两个项目之间的依赖关系并且一切都完全相同时,它们也可以工作。
不仅如此,我更愿意相信来自模板的东西不应该有编译错误。
我究竟做错了什么?