Closed xiuyangsun closed 4 years ago
Unfortunately it is hard to tell what might be going on from a few code snippets. Your @Configuration
class has @EnableWebMvc
on it. Adding this annotation switches off Spring Boot's WebMvcAutoConfiguration
which is not recommended for most cases. Are you sure that's what you intended to do? Another thing to note is that Spring Boot 2.0.x
has reached end of life. Please upgrade to Spring Boot 2.2.x.
If none of those two things solve your issue, we would need a small sample that we can run to reproduce the issue in the form of a zip file or a github repository. Since the application runs fine locally, the issue might not be in Spring Boot.
Hi @mbhave, I have resolved the issue, I used AWS serverless spring boot 2 prototypes to rebuild the project, it is working now. This is the Github repo I'm referencing https://github.com/awslabs/aws-serverless-java-container
The @EnableWebMvc
is required by AWS lambda function to run spring boot rest API, but I move the annotation to the Controller rather than using the configuration file. And now it is working for Sping boot from version 2.0.X to 2.2.4. Thanks!
I'm glad to hear that you've got it working, @xiuyangsun. Thanks for letting us know.
By moving @EnableWebMvc
to your Controller
, I suspect you've hidden it such that Spring Boot's auto-configuration of Spring MVC is now taking effect. As @mbhave explained above, not using @EnableWebMvc
is what we recommend. If you really want to use @EnableWebMvc
, it should go on a @Configuration
class as noted in its javadoc.
I'm creating a spring boot function and running it on aws lambda, it is working with spring boot 1.5.9, but when I upgraded to 2.x, aws is throwing this exception while the application runs fine on local.
I have looked into it for several days, still couldn't find what the problem is, could anyone please help me with it? My code is: Configuration:
DynamoDBConfigProd:
Application:
LambdaHandler:
pom.xml