Maven的dependency没有设置version问题记

Maven的dependency没有设置version问题记

今天一个同事问了在工程里没有看到某个dependency设置version的话,是如何确定的版本呢?

<dependency>
	<groupId>org.elasticsearch.client</groupId>
	<artifactId>transport</artifactId>
</dependency>

查了一下SO,主要说的来自dependencyManagement和transparent dependency。

使用mvn dependency:tree -DskipTests > a.txt输入文件,也没有发现哪里定义了版本。

然后发现了一个命令mvn help:effective-pom可以查看每个module具体生效的pom。

The effective-pom goal is used to make visible the POM that results from the application of interpolation, inheritance and active profiles. It provides a useful way of removing the guesswork about just what ends up in the POM that Maven uses to build your project. It will iterate over all projects in the current build session, printing the effective POM for each.

内容大概是下面的格式:


    4.0.0
    xxx.xxx.xxx
    xxx-xxx
    1.0-SNAPSHOT
    pom
    
      xxx-xx-xx
    
    
      utf-8
    
    
      
        ...
      
    
    
      ...
    
    
      ...
    
    
      ....
    
    
      ...
    
    
      ...
    
    
      ...
    
  

可以再加上-Dverbose=true, 输出的更直观。


          org.elasticsearch.client  
          transport  
          5.2.2  

附录

  1. [Maven Helper插件]([https://maven.apache.org/plugins/maven-help-plugin/usage.html#::text=The%20help%3Aeffective%2Dpom%20Goal,uses%20to%20build%20your%20project.](https://maven.apache.org/plugins/maven-help-plugin/usage.html#::text=The help%3Aeffective-pom Goal,uses to build your project.))
  2. SO问题的链接

你可能感兴趣的:(Maven)