There are four built-in servers in SpringBoot: Jetty, Netty, Tomcat, and underow.

The Tomcat server is used to start SpringBoot by default. The tomcat server is used by SpringBoot because the spring-boot-stater-web coordinates are imported in pom. XML and already depend on tomcat coordinates. (Condition is the condition that determines whether to import a coordinate and then creates a bean.)

So, if we don’t want to start with a Tomcat server, here’s how:

1. Exclude tomcat dependency in spring-boot-stater-web coordinates

2. Add the coordinates of other Web servers under POM.xml

3. Start the project

The operation is as follows:

###1, exclude tomcat dependency

 <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>spring-boot-starter-web-tomcat</artifactId>
                <groupId>org.springframework.boot</groupId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
Copy the code

Add the coordinates of other services

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
Copy the code

###3. Start the project

The console shows jetty server, so the switch is successful! SpringBoot cuts for a built-in Web server super simple

If you run into problems with this code please add to it 960513! Help you quickly master this function code!