Building a traditional WAR file instead of using a JAR

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 want to prevent the Tomcat server from being 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 or Weblogic, or a web server, such as Tomcat.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset