JHipster is a Yeoman generator used to create Spring Boot and AngularJS apps.
Creating a JHipster app
To begin, make sure you have the JHipster dependencies installed. Then generate a new JHipster app (make sure you choose PostgreSQL for the database. I’ve included my choice for the other setup questions):
Now you can get it ready for Heroku.
Preparing for Heroku
Create a Heroku account and install the Heroku Toolbelt.
Now run the sub-generator to prepare the application for Heroku:
This will actually provision a new Heroku app, and deploy a WAR file to it. That’s not the goal of this article, but it will ensure that your app is prepared with a PostgreSQL database and some other things.
NOTE: It is very likely that the app will timeout during the boot process, and the app will fail to start. Heroku imposes a default boot-time limit of 60 seconds, and Spring’s auto-configuration takes up a good portion of that. Add to that Tomcat’s JAR scanning and booting under 60 seconds it tough. However, this is easy to remedy by simply asking Heroku Support to increase your boot timeout to 120 seconds.
When the Heroku app was provisioned, a Git repository was also created with a Git remote for Heroku. Before moving on, make sure you’ve committed everything to this repo:
Now you can deploy to that Heroku Git remote.
Deploying with Git
Check that your Git repo has the Heroku remote by running this command:
Now, preare the remote Heroku application for JHipster by adding the Node.js and Java buildpacks:
Then define the Maven options such that the correct profiles are used:
Now prepare the NPM configuration so that Heroku can use Bower and Grunt. Run this command:
package.json now contains something like this (which you could also have added manually instead of running the
Next, add a Maven profile to clear some unneeded build-time dependencies from the slug.
Add this code to your
pom.xml in the
Now add the
pom.xml changes to Git by running these commands:
Finally, deploy with Git:
You can view your app by running this command:
If you have any trouble, reach out to Heroku Support.