Spring Boot - Deploying Spring Boot Applications to Heroku

SpringBoot - Deploying Spring Boot Applications to Heroku

I have Simple Employee Application written in SpringBoot.

# application.properties

# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true


Heroku does not have really MySQL.here we are using PostgreSQL. Update maven dependency.

		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<scope>runtime</scope>
		</dependency>


You can find here : Github



Create Heroku Account

Create Account: https://www.heroku.com/


Signup Here : https://signup.heroku.com/

Login to App : https://dashboard.heroku.com/apps


SpringBoot + Postegess from Web

Create App

On Deploy tab

  • Deployment method : Github

  • App connected to GitHub : Choose Employee App

  • Manual deploy : Click on Deployee Branch, It will deploy the code


Add Heroku PostgresSql add-on on Resourcs tab.


If any erros, check log by

If you have already created your Heroku app, you can easily add a remote to your local repository with the heroku git:remote command. All you need is your Heroku app’s name:

$ heroku git:remote -a <name>



Using Heroku CLI

The heroku create CLI command creates a new empty application on Heroku, along with an associated empty Git repository. If you run this command from your app’s root directory, the empty Heroku Git repository is automatically set as a remote for your local repository.


use the git remote command to confirm that a remote named heroku has been set for your app:

C:\\Git\\Heroku-SpringBoot-EmployeeServices\>git remote
heroku
origin


To deploy your app to Heroku, you typically use the git push command to push the code from your local repository’s master or main branch to your heroku remote, like so:

$ git push heroku main


Application deployed.


By reading postgress dependency in Maven, it will automatically configure PostgressSQL database.

Ref.

https://www.youtube.com/watch?v=k8z4UzV55ew

https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku

https://roytuts.com/how-to-deploy-spring-boot-data-jpa-application-to-heroku-cloud/

https://www.youtube.com/watch?v=E384MLaF4uU