简体   繁体   中英

Reading a version through property in Maven pom.xml dependencies

I'm trying to update jstl taglib in one project. This can be done via pom.xml in maven. Taglibs will be downloaded according to pom.xml dependency version. Now the question is:

in state before the change, the dependency of jstl in pom.xml looked like this:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>   

Now I want to update the jstl into 1.2.x version so the change is quite easy. I'll just change the version to 1.2. Maven will do the rest.

What is the difference between

<version>${jstl.version}</version>

which downloads jstl in version 1.1.2 from the repository and

<version>1.2</version>

or

<version>1.1.2</version>

what will the value ${jstl.version} in version tag do? In my case it's downloading the 1.1.2 version. But why 1.1.2 and not the newest? How does this work?

Thank you.

${jstl.version} is a property , that should be defined in your pom, something like:

<properties>
    <jstl.version>1.1.2</jstl.version>
    <!-- ... -->
<properties>
    <jstl.version>1.2</jstl.version>
</properties>


<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>${jstl.version}</version>
</dependency>   

It will download jstl-1.2.jar as your dependency. ${jstl.version} :- it will just read the property value defined in your pom.xml

${jstl.version} is just a property, that you can define on your pom.xml to have all the variables in the same place.

<properties>
    <jstl.version>1.1.2</jstl.version>
</properties>

There you can specify the version that you want, which can or not be the newest.

You can read more about it here: https://maven.apache.org/pom.html

Just as everyone posted, the reference is a property, defined in the pom.

You can also specify the version tag as followed:

<version>LATEST</version>

which responds to the latest version in the maven-repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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