删除依赖项后无法执行目标org.openjfx:javafx-maven-plugin:0.0.1:run(default-cli)

问题描述 投票:1回答:1

我有一个JavaFX Maven项目,在删除依赖项后突然引发了错误。依赖关系是在几分钟前添加的,并且项目中的任何代码都没有使用或未引用过该依赖关系。自添加依赖项以来,没有触及pom文件以外的其他文件。我确实更新/重新导入了pom文件。

该代码在添加依赖项之前和期间均按预期工作,仅在删除依赖项时停止。

错误如下:

Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.1:run (default-cli) on project computer: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)

这是我的pom文件,其中有我删除的依赖项:

<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>org.example</groupId>
    <artifactId>computer</artifactId>
    <version>1.0-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>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>14</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>14</version>
        </dependency>
        <!-- This is the dependency I removed
        <dependency>
            <groupId>com.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>4.1</version>
        </dependency>
        -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.1</version>
                <configuration>
                    <mainClass>org.computer.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

编辑:有关更多信息:当重新导入依赖项时,它仍然无法正常工作。

编辑2:我尝试从命令提示符运行。现在我收到此错误:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

我已经安装了Java 13.0.2 jdk,并且之前可以正常工作。

编辑3:

我现在尝试重新安装Intellij,Java 13.0.2 JDK,Maven,并设置新的环境变量。没用。即使是全新的JavaFX Maven项目现在也无法使用。

这是IntelliJ中的运行配置:

clean:clean javafx:compile javafx:run -f pom.xml -f pom.xml -f pom.xml

在intelliJ中运行时生成日志:

"C:\Program Files\Java\jdk-13.0.2\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\mats\Documents\intellij-projects\computer "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\lib\idea_rt.jar=50370:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version2020.1.1 clean:clean javafx:compile javafx:run -f pom.xml -f pom.xml
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< org.example:computer >------------------------
[INFO] Building computer 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-cli) @ computer ---
[INFO] Deleting C:\Users\mats\Documents\intellij-projects\computer\target
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.1:compile (default-cli) @ computer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 14 source files to C:\Users\mats\Documents\intellij-projects\computer\target\classes
[INFO] /C:/Users/mats/Documents/intellij-projects/computer/src/main/java/org/computer/io/WriteToCSV.java: C:\Users\mats\Documents\intellij-projects\computer\src\main\java\org\computer\io\WriteToCSV.java uses unchecked or unsafe operations.
[INFO] /C:/Users/mats/Documents/intellij-projects/computer/src/main/java/org/computer/io/WriteToCSV.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.1:run (default-cli) @ computer ---
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --module-path
[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.JavaFXRunMojo.executeCommandLine (JavaFXRunMojo.java:525)
    at org.openjfx.JavaFXRunMojo.executeCommandLine (JavaFXRunMojo.java:487)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:168)
    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 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:567)
    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)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
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.JavaFXRunMojo.executeCommandLine(JavaFXRunMojo.java:525)
    at org.openjfx.JavaFXRunMojo.executeCommandLine(JavaFXRunMojo.java:487)
    at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:168)
    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:567)
    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)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.314 s
[INFO] Finished at: 2020-05-12T18:47:29+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.1:run (default-cli) on project computer: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [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
java maven pom.xml
1个回答
0
投票

经过反复的反复,我找到了解决方案here

JavaFx with IntelliJ > Non modular with Maven的最后一步中指出:

  • 注意:如果JAVA_HOME未设置为14,则从Maven运行项目窗口可能会失败。为了避免这种情况,您可以添加正确的java命令到javafx-maven-plugin:<configuration><executable>/path/to/jdk-12/bin/java</executable></configuration>

由于我的JAVA_HOME设置为13.0.2,因此该解决方案适用于我。

© www.soinside.com 2019 - 2024. All rights reserved.