spring.core的此模块定义有什么问题?

时间:2018-07-05 19:23:29

标签: java spring java-module jlink moditect

我正尝试开始使用Java的新模块系统以及jlink,为此我正在使用ModiTect Maven插件。我正在为尚未定义它们的每个依赖项创建module-info.java文件,以便jlink能够正确完成它的工作。

我需要的模块之一是spring.core中的org.springframework:spring-core:5.0.7.RELEASE。我创建的module-info.java如下所示:

module spring.core {
    exports org.springframework;
}

具有此ModiTect配置:

<module>
    <artifact>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
    </artifact>
    <moduleInfoSource>
        module spring.core {
        exports org.springframework;
        }
    </moduleInfoSource>
</module>

但是当我运行jlink时,请使用以下命令:

C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanse

rver \ target \ classes-输出C:\ Users \ pupeno \ Documents \ Dashman \ code \ dashmanserver \ target \ jlink-image --launcher dashmanserver = tech.flexpoint.dashmanserver / tech.flexpoint.dashmanserver.DashmanServerApplication- -ignore-signing-information

我收到此错误:

[ERROR] Error: Error reading module: C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules\spring-core-5.0.7.RELEASE.jar

这几乎是我所获得的所有信息。该模块出了什么问题?有什么想法吗?

完整的堆栈跟踪看起来像这样,但是我认为这没有帮助:

[INFO] --- moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image (create-runtime-image) @ dashmanserver ---
[DEBUG] Configuring mojo org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image from plugin realm ClassRealm[plugin>org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@5ef04b5]
[DEBUG] Configuring mojo 'org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image' with basic configurator -->
[DEBUG]   (f) ignoreSigningInformation = true
[DEBUG]   (s) name = dashmanserver
[DEBUG]   (s) module = tech.flexpoint.dashmanserver/tech.flexpoint.dashmanserver.DashmanServerApplication
[DEBUG]   (f) launcher = org.moditect.mavenplugin.image.model.Launcher@46cb800b
[DEBUG]   (f) mavenSession = org.apache.maven.execution.MavenSession@74d3b638
[DEBUG]   (f) modulePath = [C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\classes, C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules, c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11]
[DEBUG]   (f) modules = [tech.flexpoint.dashmanserver]
[DEBUG]   (f) outputDirectory = C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image
[DEBUG]   (f) stripDebug = false
[DEBUG] -- end configuration --
[DEBUG] Running jlink: C:\Program Files\Java\jdk-10.0.1\bin\jlink --add-modules tech.flexpoint.dashmanserver --module-path c:\Users\pupeno\.m2\repository\tech\flexpoint\dashmancommon\1.0.0-beta.11;C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules;C:\Program Files\Java\jdk-10.0.1\jmods;C:\Users\pupeno\Documents\Dashman\code\dashmanse
rver\target\classes --output C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\jlink-image --launcher dashmanserver=tech.flexpoint.dashmanserver/tech.flexpoint.dashmanserver.DashmanServerApplication --ignore-signing-information
[DEBUG] Error: Error reading module: C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules\spring-core-5.0.7.RELEASE.jar
[ERROR] Error: Error reading module: C:\Users\pupeno\Documents\Dashman\code\dashmanserver\target\modules\spring-core-5.0.7.RELEASE.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.310 s
[INFO] Finished at: 2018-07-05T20:15:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image (create-runtime-image) on project dashmanserver: Execution create-runtime-image of goal org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image failed: Execution of jlink failed -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image (create-runtime-image) on project dashmanserver: Execution create-runtime-image of goal org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image failed: Execution of jlink failed
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution create-runtime-image of goal org.moditect:moditect-maven-plugin:1.0.0-SNAPSHOT:create-runtime-image failed: Execution of jlink failed
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.lang.RuntimeException: Execution of jlink failed
    at org.moditect.internal.command.ProcessExecutor.run (ProcessExecutor.java:68)
    at org.moditect.commands.CreateRuntimeImage.runJlink (CreateRuntimeImage.java:114)
    at org.moditect.commands.CreateRuntimeImage.run (CreateRuntimeImage.java:68)
    at org.moditect.mavenplugin.image.CreateRuntimeImageMojo.execute (CreateRuntimeImageMojo.java:114)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

1 个答案:

答案 0 :(得分:1)

我相信发生此错误的原因是spring.core未定义org.springframework软件包。我当前定义spring.core模块的尝试如下:

    module spring.core {
        exports org.springframework.asm;
        exports org.springframework.core;
        exports org.springframework.core.annotation;
        exports org.springframework.core.convert;
        exports org.springframework.core.convert.converter;
        exports org.springframework.core.convert.support;
        exports org.springframework.core.env;
        exports org.springframework.core.io;
        exports org.springframework.core.io.support;
        exports org.springframework.core.type;
        exports org.springframework.core.type.filter;
        exports org.springframework.core.type.classreading;
        exports org.springframework.util;
        exports org.springframework.util.xml;
        requires java.desktop;
        requires java.xml;
        requires spring.jcl;
    }