Oi Guilherme,
Ao adicionar uma dependencia no projeto parent
, os modulos filhos automaticamente terao baixados as mesmas dependencias.
Exemplo:
pom.xml
do projeto parent
:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.alura</groupId>
<artifactId>pai</artifactId>
<version>1.0</version>
<name>pai</name>
<description>Projeto pai</description>
<packaging>pom</packaging>
<properties>
<java.version>11</java.version>
</properties>
<modules>
<module>filho</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
</dependencies>
</project>
pom.xml do projeto filho
:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>filho</artifactId>
<parent>
<groupId>br.com.alura</groupId>
<artifactId>pai</artifactId>
<version>1.0</version>
</parent>
</project>
No pom.xml do projeto filho nao tem depedencias, mas automaticamente ele tera baixado o Junit, pois essa dependencia foi declarada no projeto parent.