有一個(gè) API 網(wǎng)關(guān)使用 lambda 代理調(diào)用 lambda 函數(shù)。記錄以下工作正常的身體并將身體發(fā)回:package com.dapper.cloud.function;import java.util.Map;import com.amazonaws.services.lambda.runtime.Context;import com.amazonaws.services.lambda.runtime.RequestHandler;import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;public class GrantJwt implements RequestHandler<Map<String, Object>, APIGatewayProxyResponseEvent>{ @Override public APIGatewayProxyResponseEvent handleRequest(Map<String, Object> input, Context context){ System.out.println(input.get("body").toString()); return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody(input.get("body").toString()); }} 當(dāng)我更新它以使用ObjectMapper這樣的方式時(shí):package com.dapper.cloud.function;import java.util.Map;import com.amazonaws.services.lambda.runtime.Context;import com.amazonaws.services.lambda.runtime.RequestHandler;import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;import com.fasterxml.jackson.databind.ObjectMapper;public class GrantJwt implements RequestHandler<Map<String, Object>, APIGatewayProxyResponseEvent>{ @Override public APIGatewayProxyResponseEvent handleRequest(Map<String, Object> input, Context context){ ObjectMapper m = new ObjectMapper(); System.out.println(input.get("body").toString()); return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody(input.get("body").toString()); }} 日志不顯示正文,響應(yīng)是:{ "message": "Internal server error"}我可以在 AWS Lambda 中使用 Jackson 嗎?父POM<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-lambda-java-core</artifactId> <version>1.2.0</version> </dependency>
1 回答

溫溫醬
TA貢獻(xiàn)1752條經(jīng)驗(yàn) 獲得超4個(gè)贊
好愚蠢,但如果這對(duì)任何人都有幫助,我會(huì)很高興。
ObjectMapper 不是問題。我使用 travis-ci 進(jìn)行了幾次部署,顯然如果未設(shè)置 memory_size 和超時(shí),則會(huì)使用默認(rèn)的 128 mb 和 3 秒。這不同于 512 mb 和 15 秒的新 lambda 的默認(rèn)值。
我在 travis 論壇上提出了更改此設(shè)置的請(qǐng)求。
添加回答
舉報(bào)
0/150
提交
取消