Wiremock / Elasticsearch从Java8迁移到Java9 / Java11

时间:2019-02-11 13:25:42

标签: java elasticsearch migration java-9 wiremock

我目前正在将应用程序从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

0 个答案:

没有答案