未能执行目标 org.openjfx:javafx-maven-plugin。

huangapple 未分类评论52阅读模式
英文:

Failed to execute goal org.openjfx:javafx-maven-plugin

问题

我正在尝试使用Maven在Eclipse IDE中创建一个基于Java 11的简单WorkbenchFX项目,但由于以下错误,无法使其正常工作。

**[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project test_workbenchfx: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]**

完整的控制台输出如下:

...

我使用目标**clean javafx:run**构建了Maven项目。

这是我的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.workfx</groupId>
    <artifactId>test_workbenchfx</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    ...
</project>

项目的主类是:

package com.workfx.test_workbenchfx;

import java.io.IOException;
import java.util.Locale;
import com.dlsc.workbenchfx.Workbench;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 * JavaFX Workbench App
 */
public class App extends Application {

  private Workbench wbench;

  /**
   * Application entry point
   * 
   * @param args
   */
  public static void main(String[] args) {

    // See https://stackoverflow.com/questions/64038/setting-java-locale-settings
    // https://stackoverflow.com/questions/24988491/difference-between-e-getmessage-and-e-getlocalizedmessage
    Locale.setDefault(Locale.FRANCE);

    launch(args);

  }

  @Override
  public void start(Stage primaryStage) {

    // preferences = new Preferences();

    // Initialize the workbench
    Scene myScene = new Scene(initWorkbench());

    primaryStage.setScene(myScene);
    primaryStage.setWidth(1300);
    primaryStage.setHeight(730);
    primaryStage.show();
    primaryStage.centerOnScreen();

    // initNightMode();
  }

  /**
   * 
   * @return
   */
  private Workbench initWorkbench() {

    wbench = Workbench.builder(null).build();

    return wbench;
  }

}

希望能得到帮助,因为我尝试过的所有方法(清理、更新、重新构建)都不起作用。

非常感谢您的帮助。

JD
英文:

I am trying to create a simple WorkbenchFX based project (Java 11) using Maven in the Eclipse IDE but I cannot get it to work because of the following error

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project test_workbenchfx: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

The entire console output is;

[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------&lt; com.workfx:test_workbenchfx &gt;---------------------
[INFO] Building test_workbenchfx 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ test_workbenchfx ---
[INFO] Deleting C:\Users\JD\eclipse-workspace\test_workbenchfx\target
[INFO] 
[INFO] &gt;&gt;&gt; javafx-maven-plugin:0.0.4:run (default-cli) &gt; process-classes @ test_workbenchfx &gt;&gt;&gt;
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ test_workbenchfx ---
[INFO] Using &#39;UTF-8&#39; encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ test_workbenchfx ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\Users\JD\eclipse-workspace\test_workbenchfx\target\classes
[INFO] 
[INFO] &lt;&lt;&lt; javafx-maven-plugin:0.0.4:run (default-cli) &lt; process-classes @ test_workbenchfx &lt;&lt;&lt;
[INFO] 
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.4:run (default-cli) @ test_workbenchfx ---
SLF4J: Failed to load class &quot;org.slf4j.impl.StaticLoggerBinder&quot;.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in Application start method
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:221)
	at java.base/java.util.Arrays$ArrayList.&lt;init&gt;(Arrays.java:4323)
	at java.base/java.util.Arrays.asList(Arrays.java:4310)
	at javafx.base/javafx.collections.ObservableListBase.addAll(ObservableListBase.java:246)
	at javafx.base/javafx.beans.binding.ListExpression.addAll(ListExpression.java:360)
	at com.dlsc.workbenchfx.Workbench.initModules(Workbench.java:386)
	at com.dlsc.workbenchfx.Workbench.&lt;init&gt;(Workbench.java:339)
	at com.dlsc.workbenchfx.Workbench$WorkbenchBuilder.build(Workbench.java:311)
	at com.workfx.test_workbenchfx.App.initWorkbench(App.java:76)
	at com.workfx.test_workbenchfx.App.start(App.java:59)
	at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
	... 1 more
Exception running application com.workfx.test_workbenchfx.App
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:504)
	at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:394)
	at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:100)
	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:957)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/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)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:504)
	at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:394)
	at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:100)
	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:957)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/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)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.357 s
[INFO] Finished at: 2020-04-10T19:44:03+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project test_workbenchfx: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -&gt; [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoExecutionException

I built the Maven project using the goal: clean javafx:run

This is my pom.xml file

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.workfx&lt;/groupId&gt;
    &lt;artifactId&gt;test_workbenchfx&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;properties&gt;
        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
        &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;
        &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
            &lt;version&gt;11&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
            &lt;artifactId&gt;javafx-fxml&lt;/artifactId&gt;
            &lt;version&gt;11&lt;/version&gt;
        &lt;/dependency&gt;
		&lt;dependency&gt;
		  &lt;groupId&gt;com.dlsc.workbenchfx&lt;/groupId&gt;
		  &lt;artifactId&gt;workbenchfx-core&lt;/artifactId&gt;
		  &lt;version&gt;11.1.0&lt;/version&gt;
		&lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                &lt;version&gt;3.8.0&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;release&gt;11&lt;/release&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            
            &lt;plugin&gt;
                &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
                &lt;artifactId&gt;javafx-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;0.0.4&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;mainClass&gt;com.workfx.test_workbenchfx.App&lt;/mainClass&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
			
			&lt;!-- 
			&lt;plugin&gt;
			    &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
			    &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
			    &lt;version&gt;1.2&lt;/version&gt;
			&lt;/plugin&gt;
			--&gt;

			&lt;!-- 
		    &lt;plugin&gt;
		        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
		        &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
		        &lt;version&gt;1.6.0&lt;/version&gt;
		        &lt;executions&gt;
		            &lt;execution&gt;
		                &lt;goals&gt;
		                    &lt;goal&gt;java&lt;/goal&gt;
		                &lt;/goals&gt;
		            &lt;/execution&gt;
		        &lt;/executions&gt;
		        &lt;configuration&gt;
		            &lt;mainClass&gt;com.workfx.test_workbenchfx.App&lt;/mainClass&gt;
		        &lt;/configuration&gt;
		    &lt;/plugin&gt;        
			--&gt;
			
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;

The project's main class is

package com.workfx.test_workbenchfx;

import java.io.IOException;
import java.util.Locale;
import com.dlsc.workbenchfx.Workbench;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 * JavaFX Workbench App
 */
public class App extends Application {

  private Workbench wbench;

  /**
   * Application entry point
   * 
   * @param args
   */
  public static void main(String[] args) {

    // See https://stackoverflow.com/questions/64038/setting-java-locale-settings
    // https://stackoverflow.com/questions/24988491/difference-between-e-getmessage-and-e-getlocalizedmessage
    Locale.setDefault(Locale.FRANCE);

    launch(args);

  }

  @Override
  public void start(Stage primaryStage) {

    // preferences = new Preferences();

    // Initialize the workbench
    Scene myScene = new Scene(initWorkbench());

    primaryStage.setScene(myScene);
    primaryStage.setWidth(1300);
    primaryStage.setHeight(730);
    primaryStage.show();
    primaryStage.centerOnScreen();

    // initNightMode();
  }

  /**
   * 
   * @return
   */
  private Workbench initWorkbench() {

    wbench = Workbench.builder(null).build();

    return wbench;
  }

}

I would really appreciate some help to get around this problem because nothing I've tried thus far (clean, update, rebuild) works.

Thanks a lot for your kind assistance.

JD

答案1

得分: 0

James_D 非常感谢。在阅读了您的评论后,这一点变得非常明显。我在initWorkbench()方法中将null作为参数传递给了Workbench.builder()。一旦我将其移除并添加了正确的类,它就正常工作了。

英文:

James_D Thanks a lot. It was so obvious after I read your comment. I passed null as a parameter into Workbench.builder() in the initWorkbench() method. Once I removed it and added a proper class, it worked.

huangapple
  • 本文由 发表于 2020年4月11日 02:12:35
  • 转载请务必保留本文链接:https://java.coder-hub.com/61146194.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定