A skeleton Java web app with no web framework.
Fork this project to create a repo under your own GitHub account, so that you can commit and push to it. Then clone the code from your fork onto your machine.
Make sure you have a JDK and a Java IDE installed. The skeleton web app is configured as a Maven project, so if you import it in to an IDE (e.g. IntelliJ IDEA) as a Maven project then it should download any dependencies as necessary.
If you open the project in an IDE, you should find a class called WebServer
which has a main
method.
If you run this main method then the web server should start up on your local machine.
Your app should now be running on http://localhost:5000.
Now try the following request in your browser: http://localhost:5000/api?q=Who%20wrote%20Romeo%20and%20Juliet?
This should call the code in QueryProcessor.java
.
The skeleton app comes with a small set of unit tests (see the file QueryProcessorTest
), which you can add to as you
add functionality. Run the tests using jUnit in your IDE, or from the terminal using Maven.
$ cd skeleton-java-app
$ mvn test
Just Add Respository
on the left, find your new repository a click the slider to enable.
-
Add generated Heroku Git remote to your local Git repository
This is adding a Git
remote
to your local repository so that you can rungit push heroku master
to deploy it manually.Running the following on its own doesn't work (as you won't have credentials setup)
git remote add heroku https://git.heroku.com/robbie-spike-horse-bucket.git
Use the Heroku CLI instead which asks for your credentials and logs you in somehow (as well as adding the remote above)
heroku git:remote -a robbie-spike-horse-bucket
-
Deploy automatically on push
- Run
heroku auth:token
to generate an Heroku authorisation token. - You would encrypt this value with the
travis
command but if you don't have the Travis CLI installed, use this site (use something liketobyweston/skeleton-java-app
for the repository field) - Create a
deploy
section to yourtravis.yml
(see the Travis docs) - Add the encrypted value to the
deply
section of yourtravis.yml
. - Make a change and push, check the travis log to see if it deploys.
- Run
NB. You will likely need to add the app
value if your Github repo's name doesn't match the Heroku app.
You're travis.yml
should look something like this.
language: java
jdk:
- openjdk8
script: mvn clean verify
deploy:
provider: heroku
api_key:
secure: EPYf4T4U9WfJzHi4/CVp4Eom3PXark9x5fbQ23DGw/bjGxpnqMbqv8=
app: robbie-spike-horse-bucket