Posts

Showing posts with the label Cloud Deployment

Deploy Spring Boot Application on AWS EC2 (Step-by-Step)

Deploying a Spring Boot application on AWS EC2 is one of the easiest ways to host your Java backend in the cloud. In this guide, you will build a JAR file, copy it to an EC2 instance, install Java, run the app, expose port 8080, and keep the application running in the background using nohup . Overview of the Deployment Flow A Spring Boot REST API runs locally on port 8080 An EC2 instance (Amazon Linux, t2.micro) runs in AWS You build a JAR from the Spring Boot project You SSH into EC2 and copy the JAR You install Java 17 and run the JAR file You open port 8080 in the security group After deployment, anyone can access your API using the instance's public IP or DNS . Step 1: Create & Test a Simple Spring Boot App Start with Spring Initializr: Maven project Java 17 Packaging: JAR Dependency: Spring Web Create a simple REST API: @RestController public class HelloController { @GetMapping("/hello") public Str...