Deploy your .war archive

If the result of your maven build results in a .war file, a little additional work is required.

Add the webapp-runner as dependency

To correctly execute your war file, we need you to add the webapp-runner dependency to your pom.xml file. This dependency let us start your application by starting Tomcat in a simple command.


Define your Procfile

To tell use how to start your application, you need to create a Procfile file at the root of your project: more doc about Procfiles

web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

That’s it, just commit your pom.xml and your Procfile and your app will deploy in the blink of an eye.

Cleanup your application image

When you prepare a war archive from your application. Every dependency is packaged into it and the war file should be almost autonomous. You don’t need too keep all your build dependencies in your application image.

To do so, create a .slugingore file and list the directories which are not essential to your application.


Once built, a Java application will contain the following file tree structure:


For instance, the .slugignore file may contain:


As a result, all the maven local repository will be excluded from the application image.

mode_edit Suggest edits