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