Building a WAR file

Spring Boot also provides the option of building a traditional WAR file instead of using a JAR.

First, we need to change our packaging in pom.xml to WAR:

    <packaging>war</packaging>

We would want to prevent tomcat server to be embedded as a dependency in the WAR file. ;We can do this by modifying ;the dependency on the ;embedded server (Tomcat in the following example) to have a scope of provided. The following snippet shows the exact details:

    <dependency>      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-tomcat</artifactId>      <scope>provided</scope>   </dependency>

When you build the WAR file, Tomcat dependencies are not included. We can use this WAR to deploy on an application server, such as WebSphere ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.