Heroku Cloud+Spring Boot - How to deploy the Spring Boot application on the Heroku cloud?

Hello everyone, today we will learn how to deploy a demo spring boot application on the Heroku cloud.

Let me first tell you what the Heroku cloud is!

Heroku cloud is a platform as service(PaaS) that enables developers to build, run, and operate applications entirely on the cloud. Heroku is best suitable for startups, Medium business. Heroku supports 175+ add-ons that cover various purposes – from notifications to security. In general, this cloud tech service is more user-friendly compared to EC2. Heroku helps to increase the productivity of your team by creating an environment for rolling-out and development processes.

What is Add-ons?

Add-ons are cloud services that extend Heroku apps with useful features and services, such as 

  • Datastores 
  • Logging 
  • Monitoring 
  • Content management
There are two  things to take into account:

Type of business
If you own a small business, the best option will be a Platform as a Service solution. Just choose the settings, and don’t bother with things your project doesn’t require yet.

Deployment speed
Heroku provides a ready-to-use environment where you only need to enter the code, make a few changes, and that’s it – you start running the app. Plus, you can migrate and run apps much faster compared to AWS. So if you need to make changes and fixes based on customers’ reviews – and do it fast – Heroku will be your perfect choice.

Consider Heroku if: 
  • You want to build an MVP(minimum viable product) app, deploy, and test it 
  • You will continuously improve your app based on customers’ reviews 
  • You don’t have DevOps engineers in the team 
  • The project doesn’t require huge computing power
Now I am going to tell you how to deploy a spring boot application on the Heroku cloud.

Step1:

If you have already an account on GitHub login to "https://github.com/."

or

If you not yet registered please sign up, Join

Step2:

Create a new Github repository. Click the new repository button in the top-right. You'll have an option there to initialize the repository.


Step3:

Give a unique name to your new repository.

Here, the name of our new repository is springboot_heroku_demo. We can choose the visibility public or private. 

Step4:
For our learning purpose, I created a simple restful API using spring-boot.
You can download the demo source code from the knowledgefactory Github account and upload that source code to your new Github repository.
Download  sample code:


Step5:
Commit the changes.

Step6:
Sign In to Heroku cloud console:
If you not yet registered please sign up.

Step7:
After sign in to the Heroku console, you can view the below screen.
Click the "create new app" button.

Step8:

Enter your new application name and server region

Here, I entered the "spring-boot-Heroku-demo-dev" as the application name and server location United States. Then click the "Create app" button

Step9:

Choose one deployment method.

Here I selected GitHub because our repository is Github.

Step10:
Connect your Heroku app to your Github repository.

Here, I selected our repository as springboot_heroku_demo because we are going to deploy the same on the Heroku cloud.

Step11( Optional)

Automatic deploys: enables the selected branch to be automatically deployed on this app.

Step12:

Manual Deploy: Deploy the current state of a branch to this app.

Step13:
Confirm deployment, build logs are available there for your reference.
Step14:
Test your API using postman.


More related topics,

Java - Angular - VueJS - ReactJS

NodeJS - Angular - VueJS - ReactJS

Python - Flask  - Angular - VueJS - ReactJS

Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Java Stream API - How to convert List of objects to another List of objects using Java streams?

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Java, Spring Boot Mini Project - Library Management System - Download

ReactJS, Spring Boot JWT Authentication Example

Top 5 Java ORM tools - 2024

Java - Blowfish Encryption and decryption Example

Spring boot video streaming example-HTML5

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete