我有一个Spring Boot应用程序,在本地执行时没有问题。 我想通过AWS Lambda运行该应用程序。我使用https://github.com/awslabs/aws-serverless-java-container并添加了相应的代码,如此示例中所述:https://keyholesoftware.com/2018/04/26/aws-lambda-with-spring-boot/。
问题是,它在AWS中作为Lambda运行时抛出一个无法找到Context的异常:
Caused by: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:84)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.initialize(SpringBootLambdaContainerHandler.java:181)
at com.amazonaws.serverless.proxy.spring.SpringBootLambdaContainerHandler.getAwsProxyHandler(SpringBootLambdaContainerHandler.java:77)