Q:

Maven properties tag and version for dependency

When I am using version for the dependencies from the keys which are defined in properties section of the pom file then the dependencies are not getting downloaded, but when I am hardcoding the version for dependency the dependency is getting downloaded.
<properties>
    <cucumber-version>1.2.4</cucumber-version>
    <junit-version>1.2.4</junit-version>
</properties>

<dependencies>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>{cucumber-version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>{cucumber-version}</version>
        <scope>test</scope>
    </dependency>
 <dependencies>

For the above block when I run mvn clean test then in the console the error is shown as :-
[ERROR] Failed to execute goal on project MavenCucumber: Could not resolve dependencies for project com.manish.cucumber:MavenCucumber:jar:1.0-SNAPSHOT: Failed to collect dependencies at info.cukes:cucumber-java:jar:{junit-version}: Failed to read artifact descriptor for info.cukes:cucumber-java:jar:{junit-version}: Could not transfer artifact info.cukes:cucumber-java:pom:{junit-version} from/to central (http://repo.maven.apache.org/maven2): Illegal character in path at index 61: http://repo.maven.apache.org/maven2/info/cukes/cucumber-java/{cucumber-version}/cucumber-java-{cucumber-version}.pom -> [Help 1]

Complete pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    4.0.0
    com.manish.cucumber
    MavenCucumber
    jar
    1.0-SNAPSHOT
    MavenCucmber
    http://maven.apache.org
<properties>
    <cucumber-version>1.2.4</cucumber-version>
    <junit-version>1.2.4</junit-version>
</properties>

<dependencies>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>{junit-version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>{junit-version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.2</version>
        <configuration>
            <argLine>-Duser.language=en</argLine>
            <argLine>-Xmx1024m</argLine>
            <argLine>-XX:MaxPermSize=256m</argLine>
            <argLine>-Dfile.encoding=UTF-8</argLine>
            <useFile>false</useFile>
        </configuration>
        </plugin>
    </plugins>
</build>

The Maven version which I am using is Maven-3
why the maven is trying fetch dependency from url like below :-
repo.maven.apache.org/maven2/info/cukes/cucumber-java/{cucumber-version}/cucumber-java-{cucumber-version}.pom
why not it is replacing the {cucumber-version} with 1.2.4 which is defined in properties tag

A:

Looks like your syntax is not correct. It should be prefixed with $ symbol.
Put   ${junit-version} instead of    {junit-version}

