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.
-768.png)
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.

Step 3. Add a RestController
- Go to src > main > com > example > demo
- Create a file named TestController.java next to DemoApplication.java.

We will create a basic controller with minimal code and endpoint to "/."
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

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

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.
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
- Open the AWS Management Console.
- Navigate to Elastic Beanstalk -> Click Create Application.
- Enter an Application Name and (optionally) tags.

Step 2: Configure the Environment
- Choose Environment Tier -> Web Server Environment.
- Select Platform -> Java.


Step 3: Upload Your JAR
- Under Application Code, select Upload your code.
- Give a version label.
- Select your local JAR file.
- Click Next.

Step 4: Configure Service Access
Select the service role -> aws-elasticbeanstalk-service-role.

Select your EC2 key pair and EC2 instance profile to securely log in to your EC2 instances.
-660.png)
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

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.

- 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.