为什么我不能在Maven中构建jar

时间:2016-09-27 22:15:38

标签: java maven javafx javafx-8 maven-3

我已经检查过有关类似问题的所有建议。什么都行不通。也许有人知道问题是什么? 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>pezal2</groupId>
  <artifactId>pezal2</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>  
    <plugin>
        <groupId>com.zenjava</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>8.5.0</version> 
        <configuration>
        <mainClass>com.pezal.Main</mainClass>
        </configuration>
    </plugin>
    </plugins> 
  </build>
</project>

控制台

   [ERROR] Failed to execute goal com.zenjava:javafx-maven-plugin:8.5.0:jar (default-cli) on project pezal2: Execution default-cli of goal com.zenjava:javafx-maven-plugin:8.5.0:jar failed: Plugin com.zenjava:javafx-maven-plugin:8.5.0 or one of its dependencies could not be resolved: Could not find artifact javafx-packager:javafx-packager:jar:1.8.0_20 at specified path C:\Program Files\Java\jre1.8.0_101/../lib/ant-javafx.jar -> [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/PluginResolutionException

1 个答案:

答案 0 :(得分:1)

问题是您的JAVA_HOME链接到JRE,而不是JDK。尝试

mvn package -Djava.home="C:\Program Files\Java\jdk1.8.0_101"