Search code examples
mongodbjava-9java-modulejava-platform-module-systemmongock

How to fix the issue with Java 9 Modularity after adding dependency on mongock?


We are developing Spring Boot application that is using MongoDB as storage. And we want to add to our project the DB migration tool: mongock.

in pom.xml I added a new dependency:

<dependency>
    <groupId>com.github.cloudyrock.mongock</groupId>
    <artifactId>mongock-spring</artifactId>
    <version>3.3.2</version>
</dependency>

And IntelliJ Idea advised me to add the following lines to module-info.java:

requires mongock.spring;
requires mongock.core;

After that I am not able anymore to build the project, I am getting the following error:

Module 'com.acme.project-name' reads package 'com.github.cloudyrock.mongock' from both 'mongock.spring' and 'mongock.core'

I do not know a lot about Java 9 Modularity, that why I am stuck with resolving this issue, please advice.


Solution

  • If it's worth solving this issue one could upgrade to the latest release of the artifact.

    <dependency>
        <groupId>com.github.cloudyrock.mongock</groupId>
        <artifactId>mongock-spring</artifactId>
        <version>4.0.1.alpha</version>
    </dependency>
    

    You can understand what the issue means over this and this Q&A.

    If you were to analyze the issue, you could straightforward notice that with the version 3.3.2, there are two artifacts that are brought in as a dependency under external libraries - mongock-spring and mongock-core. Further, if you look at the JARs, you would see their package structure is the same( i.e. both have classes within com.github.cloudyrock.mongock) and that is the reason for conflict that you see while they both are introduced in the modulepath.

    Edit: Extended discussions to be moved over to #mongock/issues/212.