JnG JnG - 7 months ago 20
Java Question

Missing artifact org.springframework:spring-context:jar:${org.springframework-version}

Please why am I getting this error in my pom.xml file

Missing artifact org.springframework:spring-context:jar:${org.springframework-version}


xml file

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework-version}</version>
</dependency>


Am a beginner please kindly assist

Answer

What you are seeing as ${...} is called a Maven property:

Maven properties are value placeholder, like properties in Ant. Their values are accessible anywhere within a POM by using the notation ${X}, where X is the property.

In this case, Maven is trying to access the property org.springframework-version but it isn't defined, so nothing gets replaced.

You define your own Maven properties with the help of the <properties> section in the POM:

<properties>
    <org.springframework-version>4.2.5.RELEASE</org.springframework-version> <!-- wanted Spring version -->
    <hibernate.version>5.1.0.Final</hibernate.version> <!-- wanted Hibernate version -->
</properties>