java - 为什么我的java程序无法加载maven插件?

标签 java javafx maven-plugin

我正在开发JAVAFX应用程序,并且我正在使用pom.xml文件,其中我有依赖项,它在我的上一台计算机上运行良好,但是当我将它导入到另一台电脑上,但它给了我一个错误,无法执行maven插件,我通过互联网进行了搜索,并遵循了所有可能的解决方案,但都不起作用对我来说。

现在我有一个问题,为什么我会收到此错误,无法加载 Maven 插件?

这是日志跟踪:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project EmployeeManagement: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:

这是我的 pom.xml

<?xml version="1.0" encoding="UTF-8"?>  <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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.viremp</groupId>
<artifactId>EmployeeManagement</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>EmployeeManagement</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <mainClass>com.viremp.employeemanagement.MainApp</mainClass>
</properties>

<organization>
    <!-- Used as the 'Vendor' for JNLP generation -->
    <name>VirEmp Technologies International</name>
</organization>

<build>
    <plugins>
        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.6.0</version>
            <configuration>
                <mainClass>com.viremp.employeemanagement.MainApp</mainClass>
                <bundler>EXE</bundler>
                <needShortcut>true</needShortcut>
                <appName>Employee Management System</appName>
            </configuration>
            <executions>
                <execution>
                    <id>create-jfxjar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>build-jar</goal>
                    </goals>
                </execution>
                <execution>
                    <id>create-native</id>
                    <phase>package</phase>
                    <goals>
                        <goal>build-native</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                    <configuration>
                        <excludeScope>system</excludeScope>
                        <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>

                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>${java.home}/../bin/javapackager</executable>
                        <arguments>
                            <argument>-createjar</argument>
                            <argument>-nocss2bin</argument>
                            <argument>-appclass</argument>
                            <argument>${mainClass}</argument>
                            <argument>-srcdir</argument>
                            <argument>${project.build.directory}/classes</argument>
                            <argument>-outdir</argument>
                            <argument>${project.build.directory}</argument>
                            <argument>-outfile</argument>
                            <argument>${project.build.finalName}.jar</argument>
                        </arguments>
                    </configuration>
                </execution>
                <execution>
                    <id>default-cli</id>
                    <goals>
                        <goal>exec</goal>                            
                    </goals>
                    <configuration>
                        <executable>${java.home}/bin/java</executable>
                        <commandlineArgs>${runfx.args}</commandlineArgs>
                    </configuration>
                </execution>
            </executions>  
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>8</source>
                <target>8</target>
                <compilerArguments>
                    <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <configuration>
                <additionalClasspathElements>
                    <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                </additionalClasspathElements>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>

    <dependency>
        <groupId>com.jfoenix</groupId>
        <artifactId>jfoenix</artifactId>
        <version>1.3.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>


</dependencies>

提前致谢!!

最佳答案

exec 插件执行路径 ${java.home}/../bin/javapackager 中的二进制文件。

执行时返回错误代码 1,这很可能是找不到二进制文件。

检查您是否有有效的 JAVA_HOME 并且 javapackager 是否存在。 也许你的新机器上有 jre?

关于java - 为什么我的java程序无法加载maven插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45915190/

相关文章:

java - stub 检查异常 : how to handle the exception

java - @Inject 在 @aspect 上为空

ssl - CAcert 的密码在哪里使用?

java - 如何引用资源文件夹中的 javafx fxml 文件?

java - 当两个场景都显示时,我可以在一个场景中设置另一个场景中的 TextField 值吗?

java - StackOverFlow 代码行错误

带有按钮和分页的 Javafx TableView

maven-2 - Maven 插件在构建过程中多次执行

java - 是否可以创建一个包含项目类和项目依赖项的 "uber"jar 作为带有自定义 list 文件的 jar?

maven-2 - 如何递归地解决 Maven 2 插件中的依赖项