1

我在我的应用程序中使用 firestore 并且在调用方法时

 Firestore firstoreDB = FirestoreClient.getFirestore(FirebaseApp.getInstance(env)); 

得到异常:

at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at com.google.cloud.firestore.v1beta1.stub.GrpcFirestoreStub.<clinit>(GrpcFirestoreStub.java:73)
    at com.google.cloud.firestore.spi.v1beta1.GrpcFirestoreRpc.<init>(GrpcFirestoreRpc.java:133)
    at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:80)
    at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreRpcFactory.create(FirestoreOptions.java:72)
    at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:512)
    at com.google.cloud.firestore.FirestoreOptions.getFirestoreRpc(FirestoreOptions.java:315)
    at com.google.cloud.firestore.FirestoreImpl.<init>(FirestoreImpl.java:76)
    at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:63)
    at com.google.cloud.firestore.FirestoreOptions$DefaultFirestoreFactory.create(FirestoreOptions.java:56)
    at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:499)
    at com.google.firebase.cloud.FirestoreClient.<init>(FirestoreClient.java:47)
    at com.google.firebase.cloud.FirestoreClient.<init>(FirestoreClient.java:27)
    at com.google.firebase.cloud.FirestoreClient$FirestoreClientService.<init>(FirestoreClient.java:87)
    at com.google.firebase.cloud.FirestoreClient.getInstance(FirestoreClient.java:77)
    at com.google.firebase.cloud.FirestoreClient.getFirestore(FirestoreClient.java:70)
    at com.mmt.app.firebase.ConnectToAgent.sendMessage(ConnectToAgent.java:94)
    at com.mmt.app.firebase.TestFB.connectToAgent(TestFB.java:37)
    at com.mmt.app.firebase.TestFB.main(TestFB.java:19)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.GeneratedMessageV3
    at java.net.URLClassLoader.findClass(Unknown Source)

我知道是依赖不匹配,并尝试了 firebase admin 和 firestore + guava 版本的所有排列,但没有运气。

我目前的 POM 是:

<dependency>
    <groupId>com.google.firebase</groupId>
    <artifactId>firebase-admin</artifactId>
    <version>6.9.0</version>
</dependency>
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>24.1.1-jre</version>
</dependency>
<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-firestore</artifactId>
    <version>1.20.0</version>
</dependency>
4

0 回答 0