1、创建maven工程(简单工程)
2、引入阿里依赖
<dependency>
<groupId>com.aliyun.fc.runtime</groupId>
<artifactId>fc-java-core</artifactId>
<version>1.4.0</version>
</dependency>
3、新建一个helloworld类,并实现
public class GetPoint implements PojoRequestHandler<GetPointRequest, GetPointResponse>, FunctionInitializer {
@Override
public GetPointResponse handleRequest(GetPointRequest getPointRequest, Context context) {
log.info(getPointRequest+"6666");
System.err.println("log");
System.err.println(JSON.toJSONString(getPointRequest));
GetPointResponse getPointResponse = new GetPointResponse();
getPointResponse.setTotal(6546);
return getPointResponse;
}
@Override
public void initialize(Context context) throws IOException {
FunctionComputeLogger logger = context.getLogger();
logger.debug(StrUtil.format("RequestID123 is %s %n", context.getRequestId()));
log.debug(StrUtil.format("RequestID is %s %n", context.getRequestId()));
}
}
注:官方demo中并没有实现FunctionInitializer 接口,会导致你在配置的时候初始化失败
4、正常打包工程,jar包。上传执行即可看到成功执行