如何在Spring Boot应用程序中排除嵌入式Tomcat

Dee*_*ore 4 spring-boot

我们如何从Spring Boot应用程序中排除嵌入式Tomcat服务器,以便可以在JBoss Server上运行该jar?

Yog*_*ogi 7

您可以在pom文件中排除:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>tomcat-embed-el</artifactId>
            <groupId>org.apache.tomcat.embed</groupId>
        </exclusion>
        <exclusion>
            <artifactId>tomcat-embed-core</artifactId>
            <groupId>org.apache.tomcat.embed</groupId>
        </exclusion>
        <exclusion>
            <artifactId>tomcat-embed-websocket</artifactId>
            <groupId>org.apache.tomcat.embed</groupId>
        </exclusion>
    </exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)

您可以通过链接查看此屏幕截图

嵌入式servlet容器上的Spring文档


小智 6

您可以按如下方式修改 POM.xml 文件:

  <!-- Removing the dependency for the embedded tomcat -->
            <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>
Run Code Online (Sandbox Code Playgroud)