Category: spring_boot
Deploying Spring Boot REST APIs to AWS
Published on 08 Jul 2026
Explanation
Package the Spring Boot application into a JAR file.
Code:
mvn clean package
Explanation
Launch an AWS EC2 instance and install Java.
Code:
sudo apt install openjdk-21-jdk
Explanation
Upload the application JAR to the EC2 instance.
Code:
scp app.jar ubuntu@EC2_IP:/home/ubuntu
Explanation
Run the Spring Boot application.
Code:
java -jar app.jar
Explanation
Allow port 8080 in the AWS Security Group to access the API.
Code:
http://EC2_PUBLIC_IP:8080/students