Junior — Middle
How to determine dependency versions in the main pom.xml file when using Maven?
sobes.tech AI
Answer from AI
In Maven, dependency versions are usually specified in the main pom.xml file within the <dependency> tag through the <version> element. For example:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.20</version>
</dependency>
For convenience and version management, <properties> are often used, where versions are set as variables and then referenced:
<properties>
<spring.version>5.3.20</spring.version>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
This makes updating versions and maintaining consistency in the project easier.