I have been studying Amazon Web Services, and I realized deploying Java applications on Amazon Elastic Beanstalk (EB) is a little different from deploying apps that do not require compilation to run. So this took a lot of my time and I decided to share a simple example of deploying a Java application to Elastic Beanstalk by using Amazon CDK. We can also do this in lots of different ways such as using EB CLI, but I am going to talk about deploying by using CDK CLI.
Create Your Application
Before starting, you can check the repository that includes completed SpringBoot and CDK projects on GitHub.
First, we need to create a simple Spring boot app, you should add the Spring Web package while you are creating this. You can initialize a spring boot project from here if you do not have IntelliJ Idea Ultimate. After initializing the project, you should build your application to a jar: