从Gradle中的Spring Boot中排除Tomcat依赖项

我正在将Spring Boot" title="Spring Boot">Spring Boot与Jetty一起使用,看来我不能在Gradle构建文件中排除所有Tomcat依赖项。

build.gradle的相关部分:

compile("org.springframework.boot:spring-boot-starter") {

exclude module: "tomcat-embed-el"

}

compile("org.springframework.boot:spring-boot-starter-jetty")

compile("org.springframework.boot:spring-boot-starter-web") {

exclude module: "spring-boot-starter-tomcat"

}

但是,当我运行gradle dependencies部分tomcat时,仍然存在,并导致WebSockets出现问题:

...

|

+--- org.springframework.boot:spring-boot-starter-web: -> 1.4.1.RELEASE

| +--- org.springframework.boot:spring-boot-starter:1.4.1.RELEASE (*)

| +--- org.hibernate:hibernate-validator:5.2.4.Final

| | +--- javax.validation:validation-api:1.1.0.Final

| | +--- org.jboss.logging:jboss-logging:3.2.1.Final -> 3.3.0.Final

| | \--- com.fasterxml:classmate:1.1.0 -> 1.3.1

| +--- com.fasterxml.jackson.core:jackson-databind:2.8.3

| | +--- com.fasterxml.jackson.core:jackson-annotations:2.8.0 -> 2.8.3

| | \--- com.fasterxml.jackson.core:jackson-core:2.8.3

| +--- org.springframework:spring-web:4.3.3.RELEASE

| | +--- org.springframework:spring-aop:4.3.3.RELEASE (*)

| | +--- org.springframework:spring-beans:4.3.3.RELEASE (*)

| | +--- org.springframework:spring-context:4.3.3.RELEASE (*)

| | \--- org.springframework:spring-core:4.3.3.RELEASE

| +--- org.springframework:spring-webmvc:4.3.3.RELEASE

| | +--- org.springframework:spring-aop:4.3.3.RELEASE (*)

| | +--- org.springframework:spring-beans:4.3.3.RELEASE (*)

| | +--- org.springframework:spring-context:4.3.3.RELEASE (*)

| | +--- org.springframework:spring-core:4.3.3.RELEASE

| | +--- org.springframework:spring-expression:4.3.3.RELEASE (*)

| | \--- org.springframework:spring-web:4.3.3.RELEASE (*)

| \--- org.springframework.boot:spring-boot-starter-tomcat:1.4.1.RELEASE

| +--- org.apache.tomcat.embed:tomcat-embed-core:8.5.5

| +--- org.apache.tomcat.embed:tomcat-embed-el:8.5.5

| \--- org.apache.tomcat.embed:tomcat-embed-websocket:8.5.5

| \--- org.apache.tomcat.embed:tomcat-embed-core:8.5.5

...

为什么不spring-boot-starter-tomcat排除在外spring-boot-starter-web

回答:

啊哈,找到原因了。

我也有compile("org.springframework.boot:spring-boot-starter-

websocket")依赖,也依赖spring-boot-starter-tomcat。Gradle依赖项输出使我误认为这spring-boot-

starter-web是Tomcat仍然存在的原因。

我必须添加以下内容:

compile("org.springframework.boot:spring-boot-starter-websocket") {

exclude module: "spring-boot-starter-tomcat"

}

经验教训是,当您要排除某些内容时,请仔细检查所有依赖项,以确保将其从所有位置排除。gradle依赖输出可以得到改进以减少误导…

以上是 从Gradle中的Spring Boot中排除Tomcat依赖项 的全部内容, 来源链接: utcz.com/qa/435167.html

回到顶部