且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

部署到JBOSS时从war文件中删除嵌入式tomcat服务器[Spring-Boot]

更新时间:2021-07-15 08:59:27

如果使用maven,则需要按照pom.xml中将tomcat依赖范围设置为provided. /docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging"rel =" nofollow noreferrer> http://docs.spring.io/spring-boot /docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging

If you use maven then you need to set the tomcat dependency scope as provided in your pom.xml as described in http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging

<?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">
    <!-- ... -->
    <packaging>war</packaging>
    <!-- ... -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- ... -->
    </dependencies>
</project>

Gradle用户应使用providedRuntime,如

Gradle users should use providedRuntime as described in http://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html.

...
apply plugin: 'war'

war {
    baseName = 'myapp'
    version =  '0.5.0'
}

repositories {
    jcenter()
    maven { url "http://repo.spring.io/libs-snapshot" }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
    ...
}