Dependency Version Format: ${version.XXX}

2019-08-31 05:51发布

问题:

In my pom.xml file, I have a lot of references to the dependency version using the format {version.XXX}. For example:

    <dependency>
        <groupId>com.extjs</groupId>
        <artifactId>gxt</artifactId>
        <version>${version.gxt}</version>
    </dependency>

I'm having a hard time finding information on this kind of format. My assumption is that this is used for handling scenarios where you have multiple dependencies that reference the same artifactId. This would allow us to only maintain the version information in one place. So ${version.XXX} would mean something like "find the version attribute for the XXX artificatId referenced somewhere else".

My questions:

  1. Is my assumption correct? If not please correct me!
  2. If my assumption is correct, then are there certain rules that have to be followed to use this correctly? For example, must you first list a dependency containing a pom.xml that provides the XXX artifact version information before listing a dependency that uses the ${version.XXX} format?

回答1:

This is just a property replacement, so somewhere in either this pom or in one of the parents you must list the version as a property, like this:

<properties>
    <version.gxt>your version goes here</version.gxt>
</properties>


标签: maven pom.xml