user1156596
user1156596

Reputation: 601

Maven dependency version notation in pom files

I have viewed various tutorials that show how to list a dependency and have noticed the version number for dependencies being written in two different ways.

In one tutorial the version number is written: 3.8.1.

In another tutorial it's written: ${org.springframework-version}

Where/how does it extract the version number in the second example?

Thank you.

Upvotes: 1

Views: 291

Answers (2)

Koekje
Koekje

Reputation: 777

You can define this as a property in your pom.xml:

<properties>
    <org.springframework-version>3.8.1</org.springframework-version>
</properties>

The latter is how you reference to this defined version.

Upvotes: 1

Javier
Javier

Reputation: 12388

In the second case ${org.springframework-version} references a property from the properties section of the pom.

   <properties>
        <org.springframework-version>3.8.1</org.springframework-version>
   </properties>

That approach is useful if you have several dependencies which share the same version number (as it is the case of Spring)

Upvotes: 2

Related Questions