繁体   English   中英

如何使用 firebase 导出 javafx-maven 项目

[英]how to export a javafx-maven project with firebase

现在我已经让我的项目在mvn javafx:run上运行。 但是执行mvn javaFx:jlink需要模块描述符。 创建模块信息文件后,有一些与 firebase 相关的错误。

一些进口进口:

import com.google.api.core.ApiFuture;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.firestore.*;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;

在模块信息文件中需要:

requires com.google.api.apicommon;
requires com.google.auth.oauth2;
requires firebase.admin;
requires google.cloud.firestore;

错误:

[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:run (default-cli) on project RathnapuraLabs: Error: Unable to execute mojo: Compilation failure: 
[ERROR] /C:/Users/Eshaka/IdeaProjects/RathnapuraLabs/src/main/java/back_end/TestManager.java:[14,35] cannot access com.google.cloud.Service
[ERROR]   class file for com.google.cloud.Service not found
[ERROR] /C:/Users/Eshaka/IdeaProjects/RathnapuraLabs/src/main/java/back_end/DBHandler.java:[69,33] cannot access com.google.auth.Credentials
[ERROR]   class file for com.google.auth.Credentials not found
[ERROR] /C:/Users/Eshaka/IdeaProjects/RathnapuraLabs/src/main/java/back_end/DBHandler.java:[100,85] cannot access com.google.cloud.Timestamp
[ERROR]   class file for com.google.cloud.Timestamp not found

我该如何解决这个错误?

我想出了一个更简单的方法来导出所有依赖项和所有(包括firebase)。 只需将maven-shape-plugin用于 package。

  1. 将以下插件添加到 pom.xml

     <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>Launcher</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
  2. 您需要创建另一个 class 主调用主 function 的主 javafx ZA2F2ED4F8DCEBC2CBBDZ21A2 扩展下面的应用程序

     public class Launcher { public static void main(String[] args) { AppInit.main(args); } }
  3. 最后运行mvn clean package

我之前确实遇到过类似的问题,这表明您在 pom.xml 中缺少一些依赖项:

[ERROR]   class file for com.google.cloud.Service not found
[ERROR]   class file for com.google.auth.Credentials not found
[ERROR]   class file for com.google.cloud.Timestamp not found

确保你包括他们。 您可以在此处看到类似的问题。 确保在包含依赖项后解决所有冲突,否则您将获得:

模块“com.example”从“package.example”和“package.example”中读取 package“package”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM