I am trying to setup firebase admin sdk in a Java project. Following the steps at https://firebase.google.com/docs/admin/setup#add_the_sdk I successfully added the sdk by adding the dependency to my build.gradle using,
dependencies {
compile 'com.google.firebase:firebase-admin:5.0.0'
}
then ran gradle build which returned BUILD SUCCESSFUL.
The next step in the guide uses multiple Firebase classes which I do not know where to locate. It tells me to initialize the SDK by using:
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
The guide doesn't show where to import these Firebase classes from either. I assume the classes were downloaded after I ran build.gradle but I cant seem to locate any of these classes. Does anyone know what location the gradle should've downloaded it to or what import I must use?
The guide need more precise contents and example.
I have integrated Firebase with my current Spring boot project by following these blog savicprvoslav/Spring-Boot-starter , it was out dated too as using new Firebase sdk is strongly recommended. You can check my question and answer here with sample updated code. Stakoverflow The blog suggested to use this code within a configuration file (with @Configuration annotation ).
The Java quickstart may be a good place to look.
The Database.java file has some of the imports you're looking for:
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.auth.FirebaseCredentials;
import com.google.firebase.database.*;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With