Skip to content

How to migrate Spring Boot – From Jar to War

Spring Boot - From Jar to War

In this article I’ll enumerate the few steps to migrate Spring Boot Project Configuration – From Jar to War File. Let me start with – if you’ve started your project from the scratch with the idea of building a war file, you could select this option on This way you will not need any additional changes. But, if you’ve selected the jar building option, or you’ve downloaded a project from the Internet with the  default Maven builder – you could use the following changes. If your building engine is Gradle, the steps probably will be similar.

    •  You need a child of <parent> that is <packaging>war</packaging>
    • If you don’t have the following dependency, add it. It is the servlet container dependencies:
  • A Default Spring Boot Java Main Class usually has a public static void main method, it usually has @SpringBootApplication. It may has @ComponentScans, @EntityScan, @EnableJpaRepositories – with scanning java packages or some other parameters. For a Java Spring Boot Web App to start as Web App the main class also needs: extends SpringBootServletInitializer, and a method:
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
     return application.sources(VideoConverterWebApplication.class);

After these updates, the mvn package command should produce Spring Boot Application packaged as war file instead of jar. The build file will most likely deploy successfully onto your favorite Servlet/JSP – web container.

Leave a Reply

Your email address will not be published.