我一直在尝试在 Java 应用程序中设置 Firestore,但应用程序一直挂起。这是代码:
public FirestoreDB(AppPlugin plugin) {
this.plugin = plugin;
try {
Anpr.getLogger().info("App: Initializing FirestoreDB...");
serviceAccount = Files.newInputStream(Paths.get(FIREBASE_ADMIN));
Anpr.getLogger().fine("App: Got service account file.");
credentials = GoogleCredentials.fromStream(serviceAccount);
Anpr.getLogger().fine("App: Got credentials.");
options = FirebaseOptions.builder()
.setCredentials(credentials)
.build();
Anpr.getLogger().fine("App: Got options.");
firebaseApp = FirebaseApp.initializeApp(options);
Anpr.getLogger().fine("App: FirebaseApp initialized.");
db = FirestoreClient.getFirestore(firebaseApp);
Anpr.getLogger().info("App: FirestoreDB initialized.");
} catch (Exception e) {
Anpr.getLogger().severe("App: Error initializing FirestoreDB.");
Anpr.getLogger().fine(Utils.PrintException(e));
}
}
该程序始终显示“应用程序:已获得凭据”。行,但之后什么都没有,甚至没有错误。它只是挂起。这与我们在不同应用程序中的设置完全相同,并且可以完美运行。
我尝试了很多方法来解决这个问题,例如使用默认实例、FirestoreOptions,以及完全跳过它并直接调用 FirestoreClient.getFirestore()。没有任何效果,它只是不断挂起。
这是我的 gradle.build 文件:
apply plugin: 'java'
dependencies {
compile project(':anprcore')
compile 'com.google.firebase:firebase-admin:6.8.1'
compile 'com.google.api:api-common:1.7.0'
compile 'com.google.auth:google-auth-library-oauth2-http:0.11.0'
compile 'com.google.cloud:google-cloud-firestore:0.61.0-beta'
compile 'com.google.code.gson:gson:2.9.1'
compile 'com.google.http-client:google-http-client-jackson2:1.25.0'
compile 'com.google.http-client:google-http-client:1.25.0'
testCompile 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testCompile 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
}
configurations.all {
resolutionStrategy {
force 'com.google.guava:guava:19.0'
}
}
test {
// useJUnitPlatform()
}
task copyJar(type: Copy, dependsOn: jar) {
from 'build/libs/appplugin.jar'
into '../anprcore/lib/'
}
build.dependsOn {
copyJar
}
我知道我这里拥有的所有库都相当过时,我们在程序的其他地方有很多遗留的东西,而且我没有足够的技能来完成所有冲突解决来更新所有内容。这些也是我们在工作应用程序中拥有的所有内容的精确版本(构建文件实际上是复制粘贴)。
任何帮助将不胜感激。
如果我能给零星我会的。无缘无故地暂停了我的帐户。不让我取钱。即使他做了他们要求的一切并花了很多时间,但我从来没有给过我的朋友如果他们有 4 个朋友注册就能保证的美元。现在他们试图保留存入的钱。完全是骗局。向 Marketpeace.net 提出投诉