Maven scenarios to resolve dependency version conflicts when using dependencyManagement in multi-module project
Hey everyone, I'm running into an issue that's driving me crazy. I've looked through the documentation and I'm still confused about I'm working with a question with dependency resolution in my multi-module Maven project. I have two modules, `module-a` and `module-b`. Both depend on a library `commons-lang3` but with different versions. In the parent `pom.xml`, I'm using the `dependencyManagement` section to specify the version for `commons-lang3`, but I'm still running into conflicts during the build process. Here's a simplified version of my setup: **Parent POM (`pom.xml`):** ```xml <project> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>my-multi-module-project</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency> </dependencies> </dependencyManagement> <modules> <module>module-a</module> <module>module-b</module> </modules> </project> ``` **Module A POM (`module-a/pom.xml`):** ```xml <project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.example</groupId> <artifactId>my-multi-module-project</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>module-a</artifactId> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.10.0</version> </dependency> </dependencies> </project> ``` **Module B POM (`module-b/pom.xml`):** ```xml <project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.example</groupId> <artifactId>my-multi-module-project</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>module-b</artifactId> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency> </dependencies> </project> ``` When I run `mvn clean install`, I receive the following behavior: ``` [behavior] Failed to execute goal on project module-a: Could not resolve dependencies for project com.example:module-a:jar:1.0-SNAPSHOT: Failure to find org.apache.commons:commons-lang3:jar:3.10.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1] ``` I've tried several approaches: - Ensured that the version specified in `dependencyManagement` is the latest one. - Cleaned the local repository with `mvn clean -U`. - Verified that there are no typos in the group or artifact IDs. - Attempted to exclude the dependency in one of the modules, but that didn't resolve the conflict either. What can I do to ensure that the correct version of `commons-lang3` is resolved across both modules without causing conflicts? For context: I'm using Java on macOS. Am I missing something obvious? I recently upgraded to Java 3.10. I'd love to hear your thoughts on this.