切换 WebServer, 演示如何切换成 Undertow

36 阅读1分钟

1、修改 pom.xml , 排除 tomcat , 加入 Undertow 包的依赖

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-web</artifactId>

    <!-- 引入 spring-boot-starter-web 排除 tomcat -->

    <exclusions>

        <exclusion>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-tomcat</artifactId>

        </exclusion>

    </exclusions>

</dependency>

<!-- 引入 undertow -->

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-undertow</artifactId>

</dependency>

2、因为去掉了 tomcat 的依赖,所以项目有使用到 tomcat 相关类/接口,就会报

错,注销/删除这部分代码即可 , 运行项目,完成测试

3、改回 Tomcat