微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

基于 spring 启动问题从 github repo 加载的 azure web 应用程序

如何解决基于 spring 启动问题从 github repo 加载的 azure web 应用程序

昨天我将我的 github 链接到了一个 azure 网络应用服务 我的 repo 使用 rest 请求构建,其中一些正在处理从基于 firestore 的数据库加载数据,我在 spring 附带的 tomcat 嵌入式服务器上的 localhost 上运行了所有这些 ,让 web 应用程序在空中运行,我的 post 请求从 firebase 获取资源,post 请求为我提供了一个内部 500 服务器,所以我检查应用程序洞察功能以检查我得到了什么异常

java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. 
at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:165)
at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:136)

我的 fire base 初始化代码是:

 package Model;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaSEOptions;
import org.springframework.stereotype.Service;

import javax.annotation.postconstruct;
import java.io.File;
import java.io.FileInputStream;
import java.util.Objects;

@Service
public class FBInitialize {
    @postconstruct
    public void initialize() {
        try {
            String fileName = "name of json file with Credential.json";
            ClassLoader classLoader = getClass().getClassLoader();
            File file = new File(Objects.requireNonNull(classLoader.getResource(fileName)).getFile());
            FileInputStream serviceAccount = new FileInputStream(file);
            FirebaSEOptions options = new FirebaSEOptions.Builder()
                    .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                    .setDatabaseUrl("https://qr-database-my data base url")
                    .build();
            FirebaseApp.initializeApp(options);
        } catch (Exception e) {
            e.printstacktrace();
        }
    }

我检查了日志,我确实收到了请求我只是收到此异常是任何人都遇到过 这个例外? 顺便说一下,在 initiazlizeApp 方法中,正在调用 getIntstance 方法

编辑: 发现异常是从哪里抛出的:

public static FirebaseApp getInstance(@NonNull String name) {
            synchronized(appsLock) {
                FirebaseApp firebaseApp = (FirebaseApp)instances.get(normalize(name));
                if (firebaseApp != null) {
                    return firebaseApp;
                } else {
                    List<String> availableAppNames = getAllAppNames();
                    String availableAppNamesMessage;
                    if (availableAppNames.isEmpty()) {
                        availableAppNamesMessage = "";
                    } else {
                        availableAppNamesMessage = "Available app names: " + Joiner.on(",").join(availableAppNames);
                    }
    
                    String errorMessage = String.format("FirebaseApp with name %s doesn't exist. %s",name,availableAppNamesMessage);
                    throw new IllegalStateException(errorMessage);
                }
            }
        }

解决方法

问题可能是github上的源代码版本。请检查 build.gradle 文件夹下的 android/app 文件。

添加以下行:

apply plugin:'com.google.gms.google-services'

相关帖子:

1. How to solve Exception Error: FirebaseApp with name [DEFAULT] doesn't exist?

2. FirebaseApp with name [DEFAULT] doesn't exist

,

我与 maven 一起工作,我还发现它与带有 google 凭据位置的 json 文件有关,因为重新打包文件将根内容更改为 BOOT-INF,因此我将 json 文件内容放入字符串中并将其转换为 Inputstream,因此 Initializeapp 和 init 将是独立的,但仍然没有乐趣:(

新更新: 现在我得到了一个不同的例外,我认为它与安全有关

java.lang.IllegalStateException: Could not find TLS ALPN provider; no working netty-tcnative,Conscrypt,or Jetty NPN/ALPN available

agian 我正在使用 maven 而不是在 android 上工作

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?