无法 运行 mvn gluonfx:link 目标来创建原生图像

Can't run mvn gluonfx:link goal to create native image

我只想从示例 Gluon 项目为 Windows 平台生成本机映像,但出现错误。我已经安装了所有要求。当 运行 mvn gluonfx:compile 时我没有得到错误,但是当我 运行 mvn gluonfx:link 时,我得到这个错误:

[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.1:link (default-cli) on project hellogluonstart: Linking failed -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.1:link (default-cli) on project hellogluonstart: Linking failed
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:956)
    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:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Linking failed
    at com.gluonhq.NativeLinkMojo.execute (NativeLinkMojo.java:54)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:956)
    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:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

这是来自日志文件的日志错误:

Creating library C:\Dev\Exercise\Gluon-Lab\gluon-samples-master\HelloFX\target\gluonfx\x86_64-windows\HelloFX.lib and object C:\Dev\Exercise\Gluon-Lab\gluon-samples-master\HelloFX\target\gluonfx\x86_64-windows\HelloFX.exp
    net.lib(DefaultProxySelector.obj) : error LNK2019: unresolved external symbol __imp_WinHttpOpen referenced in function Java_sun_net_spi_DefaultProxySelector_init
    net.lib(DefaultProxySelector.obj) : error LNK2019: unresolved external symbol __imp_WinHttpGetProxyForUrl referenced in function Java_sun_net_spi_DefaultProxySelector_getSystemProxies
    net.lib(DefaultProxySelector.obj) : error LNK2019: unresolved external symbol __imp_WinHttpGetIEProxyConfigForCurrentUser referenced in function Java_sun_net_spi_DefaultProxySelector_getSystemProxies
    C:\Dev\Exercise\Gluon-Lab\gluon-samples-master\HelloFX\target\gluonfx\x86_64-windows\HelloFX.exe : fatal error LNK1120: 3 unresolved externals

感谢 José Pereda 给出解决此错误的提示 GitHub issue.

首先,我们需要将插件存储库添加到 pom:

<project>
    ...
    <pluginRepositories>
        ...
        <pluginRepository>
            <id>sonatype</id>
            <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
        </pluginRepository>
        ...
    </pluginRepositories>
    ...
</project>

然后仅将 gluonfx-maven-plugin 版本更改为 1.0.2-SNAPSHOT。最后,再次尝试构建。