Step-by-Step Guide: Deploy a Spring Boot App to Heroku via Dashboard and CLI
This tutorial explains how to deploy a Spring Boot application on Heroku using both the web dashboard and the Heroku CLI, covering required Procfile configuration, GitHub integration, command-line installation, repository cloning, code push, log inspection, and app launch.
Heroku is a cloud platform that supports multiple programming languages and offers a free tier with five services, allowing simple application deployment via GitHub or the Heroku CLI and providing a free domain.
Deploying via the Heroku Dashboard
The example project is located at https://github.com/huiqiangyang/demo.git. To run the app, create a Procfile with the following content, which specifies the process type and start command:
web: java $JAVA_OPTS -jar target/*.jar --server.port=$PORTSteps:
Create a new Heroku app.
Select "GitHub Deploy" and connect the repository, choosing the branch to deploy.
Enable automatic deploys on code changes.
Start the deployment; the build logs show that the JAR is uploaded and the app starts within seconds.
Access the running application at https://hui-hello.herokuapp.com/.
Deploying via the Heroku CLI (Mac environment)
Install the CLI, log in, clone the app repository, and push the code:
# Install Heroku CLI
brew install heroku
# Log in to Heroku
heroku login
# Clone the app repository
heroku git:clone -a hui-hello
cd hui-hello
# Add, commit, and push changes
git add .
git commit -am "make it better"
git push heroku master
# View real‑time logs
heroku logs -t -a hui-hello
# Open the deployed app in a browser
heroku open -a hui-hello
These commands install the CLI, authenticate the user, retrieve the app code, and push it to Heroku, after which the application can be monitored via logs and accessed through the provided URL.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
