Deploy a Spring Boot Application with AWS
Last Updated :
06 Jan, 2025
A spring boot application is a Java-based web application that is built using the Spring Boot framework. Spring Boot is a project designed to simplify the development and deployment of production-ready Java applications.
Creating a Spring Boot Project with Spring Initializr: Step-by-Step Guide
Note : If you already have a spring boot application ,you can skip these steps.
Step 1 : Go to spring initializr to quickly bootstrap a simple spring boot web application.
-768.png)
Please note that I have included only one dependency, which is Spring Web, as you can see from the screenshot above.After filling all details and selecting web dependency, click on Generate or ctrl + Enter.The zipped project will be downloaded in your system.
Before deploying the application, it is essential to configure your AWS account and set up the necessary tools, such as the AWS CLI (Command Line Interface). Understanding these tools will allow you to deploy your applications efficiently.
For a deeper dive into mastering AWS services for deployment and more advanced Spring Boot integrations, consider exploring this comprehensive AWS Cloud Course. It provides hands-on experience with AWS, including practical exercises on deploying Spring Boot applications.
Step 2 : Unzip the downloaded project and import it in your IDE. I'll use VS Code for it.

Step 3: Adding a RestController to test our project.
Go to src > main > com > example > demo
src > main > com > example > demo
Note: You may have different names after com . If different project and package names are specified .
Now create a new file named TestController.java beside DemoApplication.java file.

We will create a basic controller with minimal code and endpoint to "/."
Java
package com.example.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@GetMapping("/") public String health()
{
return "Hello Geeks And Welcome to GeekForGeeks !!!";
}
}
Note : The load balancer for Elastic Beanstalk by default utilizes path "/" for health checks. Your application will keep failing health checks and display Severe status in the dashboard if that path is not defined in your controller. Either include a "/" endpoint in your rest controller code, or later change the load balancer setting to utilize an alternate path.

Step 4: Test the Application locally .Just click on Run Java Button on top right on the VS Code.Now , go to browser and open localhost:8080 . It will show like

So, our application is running properly.
Step 5: Prepare the final Jar file
Open the terminal and type (maven) mvn package to build a jar file

After successful execution it will show like this

Once your build is successful, you will find the jar file in target folder. Copy the jar file and keep it in your system safely.
How to deploy our Spring Boot Application on AWS?
There are multiple ways to deploy Spring Boot application on AWS. In this example, we will deploy a Spring Boot application on AWS Elastic Beanstalk, which is a Platform as a Service (PaaS) offering that simplifies the deployment and scaling of web applications. Elastic Beanstalk supports Java applications, making it a suitable choice for Spring Boot.
Step 1: Open AWS Console and Create and Elastic BeanStalk Application
An application is a top-level container in Elastic Beanstalk that contains one or more application environments .So, let’s create an application.Click on Create Application

Provide Application name and Application Tags(Optional).

Step 2: Scroll Down and Provide the below information :

Step 3: In Application Code , Select upload your Code :Give a Version Label, and select Local File and select the jar file saved earlier.

and click on NEXT .
Step 4: Configure Service Access.Select existing service role as aws-elasticbeanstalk-service-role

Select your EC2 key pair and EC2 instance profile to securely log in to your EC2 instances.
-660.png)
Now Click on Skip to Review ,
Step 5: Adding Environment Variable
Make Sure to add SERVER_PORT and JAVA_HOME values as
SERVER_PORT 5000
and java_home variable as,
JAVA_HOME /ur/lib/jav/java
after setting the environment variables , it will look like

Now Click On Submit.
Step 6: As soon as you click Submit.Elastic Beanstalk starts setting up your application environment. It will take few minutes , After completion the dashboard will look like this

Upon clicking on the link under domain ,we will be directed to our deployed app,
Our Spring Boot Application is Deployed on AWS Elastic Beanstalk successfully.
Similar Reads
Deploy a React Application with AWS
AWS is a subsidiary of Amazon & offers a broad range of cloud computing services, which means services using their infrastructure which is hosted on various data centers all over the world which we can rent to run our own solutions. In this article, we will learn how to deploy a React applicatio
4 min read
Dockerize Spring Boot Application with MySQL
Spring boot is the most modern framework used for building microservice-based applications today. Deploying spring boot applications requires multiple steps which require complex infrastructure and tools. Docker helps with the easy deployment of spring boot applications with the help of containers.
4 min read
Dockerize Spring Boot Application With PostgresSQL
In recent years, Docker has revolutionized the way in which we deploy and manage applications, offering a lightweight and productive solution for packaging software and its conditions into containers. For developers working with Spring Boot, a well known Java system for building undertaking grade ap
8 min read
How to Run Spring Boot Application?
Spring Boot is built on the top of Spring and contains all the features of Spring. And it is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and set
8 min read
How to Create a Simple Spring Application?
Spring Boot is one of the most popular frameworks for building Java-based web applications. It is used because it simplifies the development process by providing default configurations and also reduces boilerplate code. In this article, we will cover the steps to create a simple Spring Boot applicat
2 min read
How To Deploy Python Application In AWS?
In this article, we will explore how one as a Python developer can deploy the application by harnessing the capabilities of AWS. AWS, a leading cloud computing platform, offers a wide range of services to help developers build, deploy, and manage applications at scale EC2. It provides scalable compu
4 min read
Deploy a Website Using AWS Amplify
Pre-requisite: AWS Amplify Amplify is a suite of tools and frameworks developed by Amazon Web Services (AWS) that are used for managing hosting services for web apps as well as for launching software applications on AWS. On AWS, two well-known services include Amplify Studio and Hosting. Amplify Stu
2 min read
Add Build Properties to a Spring Boot Application
Spring Boot framework is an open-source framework for developing web applications with high performance and the Spring Boot makes it much easier to develop Spring-based applications developed by Java programming In this article, we will learn how to add build properties to a Spring Boot Application.
4 min read
Spring Boot - Application Properties
Spring Boot is built on top of the Spring Framework and includes all its features while simplifying configuration and setup. It has become a favorite among developers because it provides a rapid, production-ready environment that allows them to focus on business logic instead of dealing with complex
3 min read
Configuring Spring Boot Applications with Maven Profiles
In a software development environment, applications must often be configured differently for various environments such as development, testing, and production. Managing these configurations can be challenging, but Maven provides powerful features called profiles to handle this. Maven profiles allow
5 min read