Let’s Deploy Spring Boot App to the Cloud

A step by step tutorial

Nil Madhab
Dec 6, 2020 · 7 min read
Photo by Alex Machado on Unsplash

Introduction

Requirements

Setting up the VPS

Using your terminal

ssh root@YOUR_IP
ssh root@YOUR_IP

Updating, upgrading, and installing

apt-get update && apt-get upgrade && apt-get autoremove

Installing required packages

apt-get install openjdk-8-jdk openjdk-8-jre mysql-server maven

Setting up MySQL

mysql_secure_installation
mysql
CREATE DATABASE users;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOUR_PASSWORD';FLUSH PRIVILEGES;
exit

Setting up JAVA_HOME

nano /etc/environment
JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
source /etc/environment
echo $JAVA_HOME

Compiling our program

git clone https://PsionicAlch@bitbucket.org/java-spring-1994/api-tutorial.git
nano api-tutorial/src/main/resources/application.properties
cd api-tutorial/ && mvn clean install

Running your application

cd api-tutorial/target
java -jar tutorial-0.0.1-SNAPSHOT.jar

Testing our application

curl -H "Content-Type: application/json" -X POST -d '{
"username": "test",
"password": "test"
}' http://46.101.208.101:8080/users/register

webtutsplus

Best web and mobile development tutorials

Nil Madhab

Written by

Developer @Booking.com | ex: Samsung, OYO | IIT Kharagpur | Entrepreneur, founder of simplecoding.dev | connect me https://twitter.com/Nilmadhabmondal

webtutsplus

Find the best tutorials and courses for the web, mobile. Learn in Java, Python, Sprintboot , Android, Node.Js, SQL, AWS, Docker & more.

Nil Madhab

Written by

Developer @Booking.com | ex: Samsung, OYO | IIT Kharagpur | Entrepreneur, founder of simplecoding.dev | connect me https://twitter.com/Nilmadhabmondal

webtutsplus

Find the best tutorials and courses for the web, mobile. Learn in Java, Python, Sprintboot , Android, Node.Js, SQL, AWS, Docker & more.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store