【发布时间】:2023-04-01 13:00:01
【问题描述】:
我尝试使用org.springframework.boot:spring-boot-devtools 来加快开发速度。
我的项目使用 Firebase 对一些请求进行身份验证。 Firebase 通过以下方式初始化:
@PostConstruct
public void instantiateFirebase() throws IOException {
FirebaseOptions options = new FirebaseOptions.Builder()
.setDatabaseUrl(String.format("https://%s.firebaseio.com", configuration.getFirebaseDatabase()))
.setServiceAccount(serviceJson.getInputStream())
.build();
FirebaseApp.initializeApp(options);
}
在更改.class 文件时重新加载上下文后,Spring 报告错误:
Caused by: java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists!
at com.google.firebase.internal.Preconditions.checkState(Preconditions.java:173)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:180)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:160)
哪些 Firebase API 允许注销/销毁我应该在 @PreDestroy 中使用的 FirebaseApp?
【问题讨论】:
标签: spring firebase spring-boot-devtools