- based on the project
- as a basis of our application we gonna take minimal spring-data application with one endpoint and database
step21
from spring-steps repository.
- creating personal account on heroku.com
- creating personal SSH-keys and uploading them to heroku.com
- downloading and installing their command line tool
Heroku CLI
- creating heroku application
- making some changes in our project (extra files, configuration, etc)
- adding one more git upstream
- pushing source code to heroku upstream added in previous step
- starting enjoying working app in the browser. :)
- to start our web server on remote machine, we must take into account that we should start our web server on another port number, which will be provided us via OS environment variable
PORT
. If variable isn't provided - we must start on port5000
, seeapplication.properties
according toserver.port
section - to log in to heroku, type in the terminal
heroku login
- to create an app, type
heroku create
. As a result you will be given two links, something like that:https://mysterious-refuge-92638.herokuapp.com/ https://git.heroku.com/mysterious-refuge-92638.git
- to check whether the new upstream is added, type:
git remote -v
. The output must look like:heroku https://git.heroku.com/mysterious-refuge-92638.git (fetch) heroku https://git.heroku.com/mysterious-refuge-92638.git (push) origin https://github.com/alexr007/java-springboot-heroku.git (fetch) origin https://github.com/alexr007/java-springboot-heroku.git (push)
- add/check
properties
section intopom.xml
- add/check
dependencies
section intopom.xml
- add/check
build
section intopom.xml
- build your app:
mvn install
. As a result in the foldertarget
you must see file likejava-springboot-heroku-template-0.0.1-SNAPSHOT.jar
. It is named accordingpom.xml
sections<artifactId>
and<version>
- add
Procfile
file to the root of the project with the contents ofweb: java -jar target/java-springboot-heroku-template-0.0.1-SNAPSHOT.jar
. File must contain exactly one line. - run your app locally
heroku local:start
- go to browser and check:
http://localhost:5000/person
. Everything should work - commit everything
git commit -m "--final stage"
- push to github/gitlab:
git push origin master
- push to heroku:
git push heroku master
- test link provided by
heroku
previously on app creation step:https://mysterious-refuge-92638.herokuapp.com
with browser andPostman
- don't forget about your mappings:
/person
, etc, add them if needhttps://mysterious-refuge-92638.herokuapp.com/person
- relax
- enjoy