我目前正在将应用程序从openJDK 8迁移到openJDK 9/11。 项目使用Maven 3.5.2(也曾在3.6中试用过)。 我使用Ubuntu 18.04作为主要操作系统。 我的IDE是IntelliJ IDEA 2018.3.2
添加module-info.java
后,大多数maven依赖项在
requires ${module.name}
我在使用Elasticsearch和Wiremock时遇到问题。通过要求他们,我得到“找不到模块”
在pom.xml
中,它们包括以下内容:
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>1.58</version>
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</exclusion>
</exclusions>
<classifier>standalone</classifier>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.3.2</version>
</dependency>
在wiremock
中需要module-info.java
module com.mydomain {
requires guava;
...
...
requires wiremock;
requires elasticsearch;
exports com.mydomain.p1;
exports com.mydomain.p2;
}
在编译过程中,使用pom.xml中的wiremock
版<version>1.58</version>
时
[WARNING] Can't extract module name from mysql-connector-mxj-5.0.12.jar: TestDb.class found in top-level directory (unnamed package not allowed in module)
[WARNING] Can't extract module name from wiremock-1.58-standalone.jar: Provider class com.fasterxml.jackson.core.JsonFactory not in module
[WARNING] Can't extract module name from ical4j-3.0.1.jar: Provider class moduleName = ical4j-module not in module
[WARNING] Can't extract module name from elasticsearch-1.3.2.jar: Provider class com.fasterxml.jackson.core.JsonFactory not in module
[WARNING] ********************************************************************************************************************
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
[WARNING] ********************************************************************************************************************
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project project: Compilation failure: Compilation failure:
[ERROR] /home/artem/Documents/project/src/main/java/module-info.java:[95,14] module not found: wiremock
[ERROR] /home/artem/Documents/project/src/main/java/module-info.java:[97,14] module not found: elasticsearch
更新到新版本无济于事。如果将Wiremock与<version>2.1.6</version>
或更高版本一起使用,Intellij说module not found
可以:
requires commons.lang;
requires json;
和
[ERROR] Failed to execute goal on project project: Could not resolve dependencies for project com.mydomain:project:jar:0.0.1-SNAPSHOT: Failure to find com.github.tomakehurst:wiremock:jar:standalone:2.21.0 in https://repository.mulesoft.org/nexus/content/repositories/public was cached in the local repository, resolution will not be reattempted until the update interval of codehaus-release-repo has elapsed or updates are forced