The project includes 7 modules. And the task is to exclude transitive dependency for one library in 4 modules.
Seemingly simple way is to write in each of 4 pom files:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>3.4.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</exclusion>
</exclusions>
But is there a more optimal way? Could I, for example, create one separate util pom.xml with dependencyManagment, and "link" this pom with each module, where I want to apply this dependencyManagment ?
You can define this in the parent POM and it then be used in all modules.