Last updated 08 May 2017
Table of Contents
Heroku supports the deployment of WAR files via Git deployment (which packages the WAR file remotely) and via the Heroku Maven plugin (which packages the WAR file locally). The default server for both methods is Tomcat 8, but the platform provides the flexibility to substitute any bootable or embeddable servlet container, such as Jetty.
This article provides a general overview of the two WAR file deployment methods and discusses the tradeoffs between them.
Deployment with the Heroku Maven Plugin
Deploying a WAR file with the Heroku Maven plugin allows you to integrate the deployment process with your existing Maven process. The Heroku plugin uses the artifacts generate by your
mvn package phase, and builds them into a Slug file that is uploaded to the Heroku servers.
In this way, the Heroku Maven plugin avoids the overhead of recompiling your project remotely. This is often the preferred approach when deploying from a CI server, which may already have built your WAR file and tested it.
Deployment with the Heroku CLI
$ heroku plugins:install heroku-cli-deploy
And as long as you have a Java runtime installed locally, you can deploy with this command:
$ heroku war:deploy <path_to_war_file> --app <app_name>
The CLI plugin uses the same underlying code as the Heroku Maven plugin, but without the Maven integration. As a result, it supports many of the same configuration options but with a different mechanism. You can learn how to customize this tool in Configuring WAR Deployment with the Heroku CLI.
Git Deployment with Webapp Runner
Deploying a WAR file by pushing to a Git repository is an easy way to get started with Heroku. It also has the advantage of ensuring Dev/Prod parity. However, the compile phase of Git deployment will execute your Maven goals, which makes it slower than other deployment methods.
For more information, see our article on Deploying Tomcat-based Java Web Applications with Webapp Runner. If you’re using Gradle, see our guide to Deploy WAR files with Gradle
A number of older Heroku tools that were used to deploy WAR files may work, but are no longer being actively developed. They include:
While they may continue to work, it is strongly recommended that you upgrade to one of the other approaches described in this article.
See the Heroku DevCenter articles for more information on deploying from Eclipse, IntelliJ or a CI Server.