How to deploy Java Springboot application in Ubuntu 16.04/18.04

 



Hello Friends

Today, I am going to show you how can we deploy a Java Spring-boot application in Ubuntu 16.04/18.04


Step 1: SSH to your server


Step 2: Once you logged into server, update the Ubuntu packages
sudo apt-get update


Step 3: Install the Java package. It is required to run Jenkins.

To add the PPA, It contains the Java

sudo add-apt-repository ppa:webupd8team/java
Press Enter key to continue. It will created the keyring



Step 4: Update and Package after keyrings added and Run the Java Installation
sudo apt-get update
sudo apt install oracle-java8-installer


Step 6: Click OK to accept License Agreement

Click Yes to accept Oracle Binary Code License terms.


Verify the installed Java version
java -version
javac -version


Step 7: Next, we will install the maven, as it is the build tool for Java applications.
sudo apt-get install maven -y


Step 8: Now as we are going to deploy Java Spring-boot application.


For this demo in going to clone a sample Java Spring-boot application from the GIT Hub.

So, first check if GIT already installed then proceed otherwise we need to install GIT first in order to clone a sample application from the GIT Hub.
sudo apt-get install git -y


Now, I am cloning a Java Springboot sample application from GIT Hub


[You can clone it any location wherever you want]
sudo git clone https://github.com/spring-projects/spring-petclinic.git
Now the Application clone into root directory.

Now, I will go into directory spring-petclinic
cd spring-petclinic
Note : Inside the folder there is a file name “pom.xml” where all the installation dependencies are mentioned for java springboot application
Step 9: We will now build the java application with the package we install called “maven”


[Remember, run this command from the folder where “pom.xml” is present]
maven clean package


After run this command, there will be new folder created name “target”. Where our Java Springboot application will be deployed the file extension end with .jar



Step 10: Finally, now we are going to run this application, so that this will be accessible through browser

To run the application in the background we will run the following command otherwise we have to create a service to this application.

This command will be run after enter to the folder name target as you can see that our application is in the target folder name “spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar”
nohup java -jar -Dspring.profiles.active=test spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar &


In the above command we are using nohup in the beginning and & at the end to run the application in background


Note: Remember as this is a Java application this will be accessible on the browser IP address of the machine along-with port 8080


Popular posts from this blog

How to Convert PEM KeyFile into PPK KeyFile and vice versa?

How to transfer Google Cloud Storage One account data to Google Cloud another account?

MySQL Commands, Administration, Backup, Restore