Skip to main content

Command Palette

Search for a command to run...

Deploy Spring Boot Application on AWS with script

Updated
•1 min read•View as Markdown

Step 1: Add maven dependecy

Use the following command to add maven dependency

sudo apt-get install maven

Step 2: Clone the project

Clone your spring boot project into the directory

Step 3: Clean Install

Run the following command to generate the jar file

mvn clean install

Step 4: Run the jar file

Run the jar file inside target folder using the command

java -jar ./target/${jarname}.*.jar

Step 5: Combine all into one File

Go to the path /usr/local/bin and create a file, lets call it deploy

sudo vi /usr/local/bin/deploy

insert the following lines

#!/bin/bash
fuser -k 8080/tcp
cd ~/project-folder
git pull && mvn clean install -DskipTests && nohup java -jar ./target/*-*.jar &

Save and close

Make Runnable with

sudo chmod +x deploy

now use deploy command to deploy the code at once

More from this blog

A Feeble Journey

78 posts