• 将SpringBoot默认使用的tomcat替换为undertow


    随着微服务的兴起,越来越多的互联网应用在选择web容器时使用更加轻量的undertow或者jetty。SpringBoot默认使用的容器是tomcat,如果想换成undertow容器,只需修改pom.xml文件

    修改如下:

    1.去除默认的Tomcat容器

    2.引入Undertow依赖

    <?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>com.mousewheel</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>2.0.1.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <!-- Springboot默认使用tomcat服务器,当使用undertow服务器时,需把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>
    
            <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>
  • 相关阅读:
    抓包之网络分析器- Wiresshark
    IT 技术网站收集
    XAMPP Apache + MariaDB + PHP + Perl
    http://101.132.165.115/
    LNMP 网站搭建
    10X Genomics : Single Cell Gene Expression
    PacBio下机数据如何看?
    光模块
    ubuntu 'yuan' update
    Perl 中 `cmd` 和system"cmd"的区别
  • 原文地址:https://www.cnblogs.com/mousewheel/p/java.html
Copyright © 2020-2023  润新知