Maven How to use properties

Custom properties and variables are defined in the properties tag in the pom.xml file

<project>

  <properties>
     <java.lib1.version>1.0</java.lib1.version>
  </properties>

</project>

The property name can be any value. It is referenced by calling ${propertyname}

Example:

In this example the property java.lib1.version is defined with the value 1.0.0.RELEASE. The dependency calls the property ${java.lib1.version}, that maven automatically replaces it with the value 1.0.0.RELEASE

  <properties>
    <java.lib1.version>1.0.0.RELEASE</java.lib1.version>
  </properties>

  <dependencies>

	<dependency>
	  <groupId>groupId</groupId>
	  <artifactId>artifactId</artifactId>
	  <version>${java.lib1.version}</version>
	</dependency>
  </dependencies>

References:

Maven

Recent Comments