Deploying Spring Boot applications as old-fashioned WAR files

Home » Blog » Software » Enterprise Software » Deploying Spring Boot applications as old-fashioned WAR files

Spring Boot is an opinionated convention-over-configuration framework for creating stand-alone Spring-based Java applications.

Its objective is to provide you with a preselected best practice choice of libraries (both from the Spring platform and by third parties) for a given task, e.g.

  • building a web application that connects to a database and provides REST resources
  • creating a scheduled batch task that exports and aggregates data from various data sources
  • providing an API that connects to SOAP Web Services

It both helps you with getting started quickly and allows you to go about application development in a pattern-like manner that makes application behaviour more predictable and easier to understand.

In keeping with that stand-alone, cookie cutter approach the usual way Spring Boot applications are deployed is as a JAR file (including an embedded web container such as Tomcat if your application is a web app). This allows you to run your application right away without any configuration hassle. In addition to that, this self-contained approach is expedient to the microservices design pattern, which has made Spring Boot a prime choice for modern microservice architectures.

Sometimes however for instance due to existing infrastructure that can’t be changed quickly it might be necessary to deploy applications – web applications in particular – the old-fashioned way as WAR (Web application ARchive) files in existing servlet containers or application servers.

In order to do so you only have to make a few changes to your application configuration (as described in the Spring Boot documentation part on traditional deployment):

  • Provide a SpringBootServletInitializer and configure() method:

    public class Application extends SpringBootServletInitializer {
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        public static void main(String[] args) throws Exception {
  , args);
  • Change the packaging option in the application’s pom.xml to war:

  • Finally, tell Maven to not use the provided embedded Tomcat servlet container in production in order to not interfere with the existing servlet container you deploy the WAR file to:

If you’d like to know more about Spring Boot application deployment in general and converting Spring Boot applications from JAR to WAR deployments in particular please have a look at these posts on the Spring website:

If you’d like to know more about Spring Boot deployments and various best practices regarding Spring Boot please subscribe to this mailing list for more information on my upcoming guide “Spring Boot – Best Practices“:

* indicates required

Leave a Comment

* Checkbox GDPR is required


I agree

By continuing to browse the site you agree to our use of cookies. Privacy Policy

Privacy Preference Center

Strictly necessary

These cookies are necessary for the site to function.

PHPSESSID: Preserves user session state across page requests.

__cfduid: Used by the content network, Cloudflare, to identify trusted web traffic.



Remembers the user's submitted data when a comment is submitted in a blog post. The purpose is to aut o-populate form fields for subsequent comments, in order to save time for the user.



Statistic cookies help us to understand how visitors interact with our websites by collecting and reporting information anonymously.

_ga: Registers a unique ID that is used to generate statistical data on how the visitor uses the website.

_gat: Used by Google Analytics to throttle request rate.

_gid: Registers a unique ID that is used to generate statistical data on how the visitor uses the website.

collect: Used to send data to Google Analytics about the visitor's device and behaviour. Tracks the visitor across d evices and marketing channels.



We use Wordfence to secure our website against hacking attempts:


Close your account?

Your account will be closed and all data will be permanently deleted and cannot be recovered. Are you sure?