mvn依赖项的替代项:查看父版本的树

时间:2018-07-24 22:30:51

标签: maven spring-boot

当您运行mvn dependency:tree到某个Spring Boot项目时,您会看到以下内容:

[INFO] com.example:demo:jar:1.0.0-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.0.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.0.2.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-context:jar:5.0.6.RELEASE:compile
[INFO] |  |     +- org.springframework:spring-aop:jar:5.0.6.RELEASE:compile
[INFO] |  |     +- org.springframework:spring-beans:jar:5.0.6.RELEASE:compile
[INFO] |  |     \- org.springframework:spring-expression:jar:5.0.6.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.2.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.2.RELEASE:compile
[INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  +- org.springframework:spring-core:jar:5.0.6.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.0.6.RELEASE:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.19:runtime

当您不重写时,所有工件都从父pom获得了默认版本。是否有一些Maven命令来检查项目父项的信息(版本)?

所以当pom.xml中存在

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
</parent>

我想看到类似的东西

[INFO] +- org.springframework.boot:spring-boot-starter-parent:jar:2.0.1.RELEASE:compile

1 个答案:

答案 0 :(得分:1)

这没有显示您想要的确切输出,但是非常相似。

mvn -Dexec.executable='echo' -Dexec.args='${project.parent.groupId}: ${project.parent.artifactId}: ${project.parent.version}' --non-recursive exec:exec -q  

在Ubuntu上测试,它在我的机器上显示如下内容:
org.springframework.boot: spring-boot-starter-parent: 1.5.9.RELEASE

-q :安静的输出,仅显示错误