Hackforge Academy

Category: spring_boot

Spring Boot App on AWS EC2

Published on 15 Sep 2026

Explanation

Create a Spring Boot executable JAR file using Maven before deploying the application to EC2.

Code:

mvn clean package

Explanation

The generated JAR file is usually available inside the target directory.

Code:

target/
  └── employee-service-0.0.1-SNAPSHOT.jar

Explanation

Install Java on the EC2 Linux server and verify the installed version.

Code:

sudo apt update
sudo apt install openjdk-17-jdk -y
java -version

Explanation

Copy the Spring Boot JAR file from the local machine to the EC2 server using SCP or another secure transfer method.

Code:

scp -i aws-key.pem \
 target/employee-service.jar \
 ubuntu@EC2_PUBLIC_IP:/home/ubuntu/

Explanation

Run the Spring Boot application on EC2 and allow the required port through the security group.

Code:

java -jar employee-service.jar

Application URL:
http://EC2_PUBLIC_IP:8080

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community