Esh*_*aka 5 java javafx jlink maven 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;
Run Code Online (Sandbox Code Playgroud)
在模块信息文件中需要:
requires com.google.api.apicommon;
requires com.google.auth.oauth2;
requires firebase.admin;
requires google.cloud.firestore;
Run Code Online (Sandbox Code Playgroud)
错误:
[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
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
我找到了一种更简单的方法来导出所有依赖项和所有(包括 firebase)。只需使用maven-shape-plugin来打包即可。
将以下插件添加到 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>
Run Code Online (Sandbox Code Playgroud)
您需要创建另一个带有 main 的类,该类调用主 javafx 类的 main 函数,该类扩展了应用程序,如下所示。
public class Launcher {
public static void main(String[] args) {
AppInit.main(args);
}
}
Run Code Online (Sandbox Code Playgroud)
终于跑了mvn clean package
| 归档时间: |
|
| 查看次数: |
197 次 |
| 最近记录: |