Heroku + SpringBoot Deployment example – How to Deploy SpringBoot + PostgreSQL
Tags: heroku, springboot, postgres, deployment
Published: 2021-04-22 13:20:42

https://grokonez.com/spring-framework/spring-boot/deployment-spring-boot/heroku-springboot-deployment-example-how-to-deploy-springboot-postgresql-on-heroku-platform-with-heroku-cli

Heroku + SpringBoot Deployment example – How to Deploy SpringBoot + PostgreSQL on Heroku platform with Heroku CLI

Heroku is a platform as a service (PaaS) that help us to build, run, and operate applications entirely in the cloud. So in the tutorial, we show you how to deploy SpringBoot web application with PostgreSQL in Heroku.

Related posts:
- <a href="https://grokonez.com/spring-framework/use-spring-jpa-postgresql-spring-boot">How to use Spring JPA with PostgreSQL | Spring Boot</a>
- <a href="https://grokonez.com/frontend/angular/angular-deployment/how-to-deploy-angular-application-on-heroku-hosting-with-git-repository">How to Deploy Angular application on Heroku hosting with Git repository</a>

<!--more-->
<h2>Technologies</h2>
- Heroku
- Maven
- SpringBoot
<h2>Goal</h2>
We deploy a <strong>SpringBoot</strong> with <strong>PostgreSQL</strong> to Heroku platform:

<img src="https://grokonez.com/wp-content/uploads/2018/12/Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting-appdb.png" alt="Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting---app+db" width="750" height="443" class="alignnone size-full wp-image-16077" />

<img src="https://grokonez.com/wp-content/uploads/2018/12/Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting-restapi-test-getall-customer-from-db.png" alt="Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting---restapi-test-getall-customer-from-db" width="486" height="189" class="alignnone size-full wp-image-16078" />
<h2>Practice</h2>
<h3>Setup Heroku CLI</h3>
<h4>Download & Install Heroku CLI</h4>
For detail go to the <a href="https://devcenter.heroku.com/articles/heroku-cli#download-and-install">Download Heroku CLI</a>

- Install Heroku CLI on Linux:

<pre><code class="language-java">
$sudo snap install --classic heroku
</code></pre>

-> Details:

<pre><code class="language-java">
root@gkz-vps:~# sudo snap install --classic heroku
2018-12-14T07:04:55Z INFO Waiting for restart...
heroku v7.19.3 from Heroku? installed
</code></pre>
<h4>Login to Heroku</h4>
Use <code>heroku login</code> cmd to login:

<img src="https://grokonez.com/wp-content/uploads/2018/12/Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting-Heroku-Login-successfully.png" alt="Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting---Heroku-Login-successfully" width="565" height="160" class="alignnone size-full wp-image-16080" />

<img src="https://grokonez.com/wp-content/uploads/2018/12/Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting-Heroku-Login.png" alt="Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting---Heroku-Login" width="564" height="491" class="alignnone size-full wp-image-16079" />
<h4>Add Heroku SSH keys</h4>
- To check your key was added, run <code>heroku keys</code>
- If your key isn’t there, you can add it manually by running <code>heroku keys:add</code>

<img src="https://grokonez.com/wp-content/uploads/2018/12/Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting-Add-SSH-Keys.png" alt="Deploy-SpringBoot-with-PostgreSQL-on-Heroku-hosting---Add-SSH-Keys" width="520" height="448" class="alignnone size-full wp-image-16081" />
<h3>Deploy simple SpringBoot Web Application on Heroku</h3>
<h4>Create SpringBoot Project</h4>
Use <strong>SpringToolSuite</strong> to create a SpringBoot project.

- Add <code>web</code> dependency ->

More at:

https://grokonez.com/spring-framework/spring-boot/deployment-spring-boot/heroku-springboot-deployment-example-how-to-deploy-springboot-postgresql-on-heroku-platform-with-heroku-cli

Heroku + SpringBoot Deployment example – How to Deploy SpringBoot + PostgreSQL on Heroku platform with Heroku CLI