Deploy a Spring Boot Application with AWS

Last Updated : 24 Sep, 2026

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.

Step 1. Create a Spring Boot Project

  • Go to Spring Initializr to bootstrap your project.
  • Fill in the details (Group, Artifact, etc.) and add Spring Web as the dependency.
  • Click Generate (or press Ctrl + Enter).
  • A zipped project will be downloaded.

We use only the Spring Web dependency to keep it simple.

Spring Initializr

Step 2. Import the Project into Your IDE

Unzip the downloaded project and import it in your IDE. I'll use VS Code for it.

Environment

Step 3. Add a RestController

  • Go to src > main > com > example > demo
  • Create a file named TestController.java next to DemoApplication.java.

Demo application

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 GeeksForGeeks !!!";
    }
}

Step 4. Run and Test

  • Click Run Java in VS Code.
  • Open a browser and go to:

http://localhost:8080

Output

So, our application is running properly.

Step 5. Build the JAR File

Open the terminal and type (maven) mvn package to build a jar file

Build the Package

After successful execution it will show like this

Build Success

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.

Deploy to AWS Elastic Beanstalk

  • There are multiple ways to deploy Spring Boot application on AWS.
  • Here, 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: Create an Elastic Beanstalk Application

  1. Open the AWS Management Console.
  2. Navigate to Elastic Beanstalk -> Click Create Application.
  3. Enter an Application Name and (optionally) tags.

Create Application

Step 2: Configure the Environment

  1. Choose Environment Tier -> Web Server Environment.
  2. Select Platform -> Java.

Environment tier

Platform type

Step 3: Upload Your JAR

  1. Under Application Code, select Upload your code.
  2. Give a version label.
  3. Select your local JAR file.
  4. Click Next.

Application code

Step 4: Configure Service Access

Select the service role -> aws-elasticbeanstalk-service-role.

Service Access

Select your EC2 key pair and EC2 instance profile to securely log in to your EC2 instances.

EC2 key pair

Step 5: Add Environment Variables

Go to Environment Properties and set:

SERVER_PORT = 5000
JAVA_HOME = /usr/lib/jvm/java-17

after setting the environment variables , it will look like

Environment properties

Step 6: Deploy

  • Click Submit.
  • Elastic Beanstalk will launch your environment (this takes a few minutes).
  • Once ready, the dashboard will display the environment status.

Environment Overview

  • Upon clicking on the link under domain ,we will be directed to our deployed app,

Output Our Spring Boot Application is Deployed on AWS Elastic Beanstalk successfully.

Comment