Deploying Spring Boot MVC with JSP project to AWS Elastic Beanstalk

mmafrar

Afrar Malakooth

Posted on October 1, 2021

Deploying Spring Boot MVC with JSP project to AWS Elastic Beanstalk

Disclaimer: Try this at your own risk. AWS resources required for DemoApplication should be covered under the free tier. If you’re not on a free tier make sure to clean up the resources provisioned soon after trying this out. Check if there are any leftovers remaining inside an Amazon S3 bucket after deleting the application.

There are multiple options available when it comes to the deployment of a Spring Boot project. In this story, we’ll be focusing on how to deploy a project with JSP pages using a service available in Amazon Web Services.


Throughout the last couple of Medium stories, I have discussed how to create a Spring Boot project and adding different features to those projects. In order to proceed with this story you need to have a Spring Boot MVC project, if you don’t have one check out my Medium story Implementing Spring Boot MVC CRUD operations with JPA and JSP or feel free to clone the below repository.

GitHub logo mmafrar / spring-mvc-crud-example

Implementing Spring Boot MVC CRUD operations with JPA and JSP

Once you have a project to work on, open build.gradle file and under plugins change id ‘java’ to id ‘war’ and add the below dependencies to the project.

implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
Enter fullscreen mode Exit fullscreen mode

If you’re using Maven as the build tool, update the pom.xml file. Then open the main Spring Boot application and make below changes.

Next login to AWS Management Console. From the search bar look for Elastic Beanstalk and navigate to the page. Click on Create Application button to open Create a web app form. Make sure to provide a suitable name for the application. Select the values in the image for the dropdowns. Upload *.war file and click on Create application.

Create a web app form

You’ll be displayed with the steps and progress on provisioning the resources needed to deploy the application. This will take some time based on the size and resources required for the project. If the deployment was successful you’ll be seeing the shown screen.

Environment page

Click on the domain name displayed on the screen to open the application. Use Upload and deploy button to publish a different version of the code.


Happy Coding! Below is a DEV Community video I have published. Also, you might be interested to check my Medium story Setting up continuous integration in Spring Boot with GitHub and CircleCI.

Cover Image: Photo by Austin Distel on Unsplash

💖 💪 🙅 🚩
mmafrar
Afrar Malakooth

Posted on October 1, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related