Previous | |
Sparkjava_01 | Sparkjava_02 |
SparkJava: 02
Deploying the Library Tutorial App on Heroku
sparkjava-02
Part of a series of tutorial articles on building webapps with SparkJava.
Code examples referred to on this page can be found here: https://github.com/ucsb-cs56-pconrad/spark-basic-structure
A (more or less) full web app example
The repo linked to is a clone of the repo https://github.com/tipsy/spark-basic-structure.
- I cloned this to https://github.com/ucsb-cs56-pconrad/spark-basic-structure
- I then added:
- Code to set the port number from the PORT environment variable (this is needed to run on Heroku)
- Code to the Maven
pom.xml
to make a jar with dependencies - A
Procfile
that tells to run that jar on startup - Code to deploy to Heroku using the Heroku CLI
This application is described in detail in the tutorial Creating a library website with SparkJava.
You are encouraged to create a fork of my fork of that app (i.e. the one with the extra stuff to deploy easily on Heroku), clone it, and play around with the code as you read through the Creating a library website with SparkJava tutorial.
As the introduction to that tutorial says (emphasis and bulletting added):
- You will learn how to create a basic Spark application with
- filters, controllers, views
- authentication, localization, error handling, and more,
- [But] this is not really a full blown tutorial
- It’s more a description of a basic structure, with certain points of the code highlighted.
- To get the full benefit of this tutorial, please:
- clone the example on GitHub,
- run it,
- and play around.
That is what I recommend that you do next. Then, we’ll start with our basic sparkjava-01
app and add each of those things to
it, one at a time, so that you get a sense of how each of those works.
Previous | |
Sparkjava_01 | Sparkjava_02 |