【发布时间】:2019-03-08 08:49:40
【问题描述】:
下面是我的 pom.xml
<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/maven-v4_0_0.xsd">
<properties>
<jdk.version>1.8</jdk.version>
<spring.version>4.1.6.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
我可以通过'mvn dependency:tree'打印依赖树
\- org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:4.1.6.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-core:jar:4.1.6.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile
[INFO] \- org.springframework:spring-web:jar:4.1.6.RELEASE:compile
您可以看到 commons-logging 在 spring-core 下。
但是当我改到下面的时候。
<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/maven-v4_0_0.xsd">
<properties>
<jdk.version>1.8</jdk.version>
<spring.version>4.1.6.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>1.1.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
并打印以下树。
INFO] \- org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:4.1.6.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-core:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile
[INFO] \- org.springframework:spring-web:jar:4.1.6.RELEASE:compile
可以发现commons-logging丢失了。
我可以在 IDE 中点击进入 spring-webmvc 的子节点,并确认 commons-logging 存在于 spring-core-4.1.6 中。 RELEASE.pom。
我遇到了这个问题,因为我想从 spring 中排除 commons-logging 并计划使用 jcl-over-slf4j。那么为什么我使用 io.spring.platform 时会丢失 commons-logging jar 文件。谢谢。
【问题讨论】:
-
根据doc不推荐使用
commons-logging