【发布时间】:2019-09-23 15:44:16
【问题描述】:
我正在使用 Spring Boot(无服务器项目)构建应用程序以部署在 AWS Lambda 中。我有一个使用 application/x-www-form-urlencoded 的方法。当我在 localhost 415 中调用方法时出现:
内容类型 'application/x-www-form-urlencoded;charset=UTF-8' 不是 支持
我附上了方法代码和yaml配置,我认为问题是无服务器配置,因为这种方法适用于其他项目(非无服务器)。
方法:
@PostMapping(name = "/createpayment", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String createPayment(@RequestBody Payload payload) throws StripeException, IOException, MessagingException {
...
}
Yaml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Serverless Sansaru Payments - com.sansarushop.payments::sansaru-payments
Globals:
Api:
EndpointConfiguration: REGIONAL
Resources:
SansaruPaymentsFunction:
Type: AWS::Serverless::Function
Properties:
Handler: com.example.payments.StreamLambdaHandler::handleRequest
Runtime: java8
CodeUri: target/example-payments-1.0-SNAPSHOT-lambda-package.zip
MemorySize: 512
Policies: AWSLambdaBasicExecutionRole
Timeout: 30
Events:
GetResource:
Type: Api
Properties:
Path: /{proxy+}
Method: any
Environment:
Variables:
SPRING_PROFILES_ACTIVE: 'prod'
Outputs:
SansaruPaymentsApi:
Description: URL for application
Value: !Sub 'https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/ping'
Export:
Name: ExamplePaymentsApi
感谢您的帮助!
【问题讨论】:
标签: java amazon-web-services spring-boot aws-lambda yaml