简体   繁体   English

pom文件中的Maven依赖版本表示法

[英]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. 在一个教程中,版本号是:3.8.1。

In another tutorial it's written: ${org.springframework-version} 在另一个教程中写道:$ {org.springframework-version}

Where/how does it extract the version number in the second example? 在第二个示例中,它在哪里/如何提取版本号?

Thank you. 谢谢。

In the second case ${org.springframework-version} references a property from the properties section of the pom. 在第二种情况下, ${org.springframework-version}引用pom的properties部分中的properties

   <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) 如果您有多个共享相同版本号的依赖项(如Spring的情况),那么该方法很有用

You can define this as a property in your pom.xml: 您可以在pom.xml中将其定义为属性:

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

The latter is how you reference to this defined version. 后者是您如何引用此定义的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM