我正在做一个类项目,需要使用Maven作为JavaFx项目的构建工具。
这是我的pom.xml设置,我在其中使用了2个插件。根据我的理解:maven-compiler-plugin
是强制java jdk 1.8作为编译器,javafx-maven-plugin
是自动下载javafx库。
另外,我的主启动器main.java文件位于src/main/java/main/main.java
。pom.xml
与src
文件夹处于同一级别。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<fork>true</fork>
<compilerVersion>1.8</compilerVersion>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>Main.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building PhotoshopUltraLight 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.pom
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.pom (10 KB at 23.3 KB/sec)
Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/28/maven-plugins-28.pom
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/28/maven-plugins-28.pom (12 KB at 170.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/27/maven-parent-27.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/27/maven-parent-27.pom (40 KB at 446.7 KB/sec)
Downloading:
https://repo.maven.apache.org/maven2/org/apache/apache/17/apache-17.pom
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/apache/17/apache-17.pom (16 KB at 261.3 KB/sec)
Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar (50 KB at 778.5 KB/sec)
然而,编译总是失败。
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/ImageLayer.java:[3,25] error: package javafx.scene.image does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/ImageLayer.java:[4,25] error: package javafx.scene.image does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/ImageLayer.java:[5,26] error: package javafx.scene.layout does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[4,25] error: package javafx.beans.value does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[5,25] error: package javafx.beans.value does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[6,22] error: package javafx.geometry does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[7,27] error: package javafx.scene.control does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[8,27] error: package javafx.scene.control does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[9,26] error: package javafx.scene.layout does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[10,26] error: package javafx.scene.layout does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[11,25] error: package javafx.scene.paint does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/Layer.java:[12,25] error: package javafx.scene.shape does not exist
[ERROR] /mnt/c/Users/meifi/Documents/Photoshop-Ultra-Light/src/main/java/Layers/ImageLayer.java:[11,4] error: cannot find symbol
[ERROR] symbol: class ImageView
location: class ImageLayer
我不知道哪一步错了...任何想法都将不胜感激。
Oracle JDK 8与JavaFX绑定,但与OpenJDK 8无关
JavaFX也从Oracle JDK/JRE11中删除。我在JDK 11中也遇到了同样的错误。通过在pom.xml中包含以下内容解决了这个问题:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
</dependencies>
参考:
我正在尝试向现有的企业项目添加maven支持。这是一个多模块项目,前两个模块的编译和打包没有问题,但我面临编译错误,我试图在多个模块中使用相同的依赖关系。我的结构是: 我支持在Eclipse上打开的项目,它没有显示任何错误。当我从父级运行时,它成功地安装了模块1和模块2,但在模块3上失败,表明,。包裹xxx。yyy和符号XXXYYY位于模块2和3的依赖项上列出的jar中。 由于两个模块都依赖于同一
当我试图通过[mvn clean install-DskipTests]通过控制台构建项目时,我得到了一个错误。我在测试中使用testNG SoftAssert,在测试类中我刚刚添加了一个导入组织。测试NG。断言。但是看起来maven没有看到这个包。控制台出错: 包org.testng.asserts不存在 我的pom。xml看起来像
我有一个Java FX项目,正在使用maven 3.0.5进行构建。当我运行mvn package/install时,项目失败并抱怨包javafx.*不存在。据我所知,Javafx是用Java1.7封装的,所以构建过程中不采用这一点是没有意义的。当我在IDE(intellij)中编译它时,它工作得很好,然后我的maven构建也成功安装了,但是我不希望每次进行干净的安装时都要经历IDE。有什么想法吗
我有一个(看似)简单的maven问题我无法解决。在我的POM中,我指定了一个对openrdf-sesame的依赖关系,如下所示: 我有什么遗漏吗?我在我的POM中找不到任何错误。
我在Eclipse中使用maven创建了一个webapp项目。当我在命令提示符下运行命令mvn包时,它会显示folowing错误。 我尝试更改jdk和JRE。但不起作用。仍然显示相同的错误
得到如下错误: Jenkins编译错误 [javac] /var/lib/jenkins/workspace/CWL_Smoke_New/SeleniumFW/CWL_NewSuite/src/com/collegeweeklive/common/AppLibrary.java:14:错误:包org.apache.commons.lang3不存在 [javac]导入org.apache.commo