Java 9 automatic modules not found

后端 未结 1 1648
再見小時候
再見小時候 2021-02-04 10:32

I\'m trying to define a Java 9 module. I have defined something like:

module my.module.name {

}

Then many of my files started to give me error

相关标签:
1条回答
  • 2021-02-04 11:12

    Alright, the problem came out to be in the pom.xml! The reason I was getting "module not found" error during compilation was hidden behind a WARNING which I was thinking is not important, so I did not paste here in the logs. The warning was "zip END header not found". The reason for getting this warning was because I was having a "malformed jar" in my dependencies and thus the compiler was failing during parsing the module-info.java file and was producing the above errors. But which one was the "malformed" jar? It came out that it is this one (I used the method of exclusion one by one ... ):

        <dependency>
            <groupId>org.apache.sshd</groupId>
            <artifactId>apache-sshd</artifactId>
            <version>1.7.0</version>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    I got that dependency from https://mvnrepository.com when searching for apache sshd, I'm not exactly sure what does "type pom" mean, but I'm guessing, that because Apache Mina is a set of several projects, in this way you include all the projects ... anyway, I only needed apache-sshd-core from all the projects, so I changed the dependency to the following (the Apache Mina Dev community advised me about that, so thanks a lot to them!!!):

    <dependency>
        <groupId>org.apache.sshd</groupId>
        <artifactId>sshd-core</artifactId>
        <version>1.7.0</version>
    </dependency>
    

    and now all compiles just fine! Thanks a lot to everyone for the comments and the help!

    0 讨论(0)
提交回复
热议问题