Spring Boot – Use External/Local Tomcat instead of Embedded/In-built Tomcat server

Spring Boot - Use External/Local Tomcat instead of Embedded/In-built Tomcat server

Spring Boot – Use External/Local Tomcat instead of Embedded/In-built Tomcat server

Default pom.xml with exclusions tag to exclude embedded TOMCAT server:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>

     <groupId>org.test</groupId>
     <artifactId>demo</artifactId>
     <version>0.0.1-SNAPSHOT</version>
     <packaging>jar</packaging>

     <name>demo</name>
     <description>Demo project for Spring Boot</description>

     <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>1.2.1.RELEASE</version>
          <relativePath/> <!-- lookup parent from repository -->
     </parent>

     <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <start-class>demo.DemoApplication</start-class>
          <java.version>1.7</java.version>
     </properties>

     <dependencies>
          <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-web</artifactId>
               <exclusions>
                    <exclusion>
                         <groupId>org.springframework.boot</groupId>
                         <artifactId>spring-boot-starter-tomcat</artifactId>
                    </exclusion>
               </exclusions>
          </dependency>
          <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-test</artifactId>
               <scope>test</scope>
          </dependency>
     </dependencies>

     <build>
          <plugins>
               <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
               </plugin>
          </plugins>
     </build>

</project>

           Adding TOMCAT server to Eclipse or STS(Spring Tool Suite) is pretty straight forward. But the default pom.xml configuration of Spring Boot will make the application use the embedded version of TOMCAT. If you want to use local TOMCAT, you need to add an exclusions tag for TOMCAT. The bold content in the above configuration needs to be added to exlucde the embedded version of TOMCAT.

 

[ YOU MAY ALSO LIKE ]

Leave a Reply