我只是嘗試使用以下文章在 AWS Lambda 上運行 Spring Boot 應用程序:https : //github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot基本請求工作正常,但發送文件似乎會導致問題。在本地運行應用程序工作正常:@RestController@EnableWebMvcpublic class PingController { @RequestMapping(path = "/ping", method = RequestMethod.GET) public Map<String, String> ping() { Map<String, String> pong = new HashMap<>(); pong.put("pong", "Hello, World!"); return pong; } @RequestMapping(path = "/ping", method = RequestMethod.POST) public Map<String, Long> ping(@RequestParam("file") MultipartFile file) { Map<String, Long> pong = new HashMap<>(); pong.put("filesize", file.getSize()); return pong; }}/ping 上的 GET 會按預期返回有效消息:{ "pong": "Hello, World!"}向包含圖像的 /ping 發送 POST 會導致以下異常:{ "timestamp": 1540237302941, "status": 500, "error": "Internal Server Error", "exception": "org.springframework.web.multipart.MultipartException", "message": "Could not parse multipart servlet request; nested exception is java.lang.IllegalArgumentException: File path not allowed: /image.jpeg", "path": "/ping"}將以下行添加到application.properties文件中沒有幫助:spring.http.multipart.location=/tmp/甚至指定的資源是否存在都無關緊要。POST 到 /ping2(不存在)會導致相同的異常。
1 回答

ibeautiful
TA貢獻1993條經驗 獲得超6個贊
這是亞馬遜圖書館中的一個錯誤,幾天前已修復??稍诖颂帿@得更多信息。只要確保使用 1.2 或更高版本:
<dependency>
<groupId>com.amazonaws.serverless</groupId>
<artifactId>aws-serverless-java-container-spring</artifactId>
<version>1.2</version>
</dependency>
添加回答
舉報
0/150
提交
取消