我正嘗試在我的框架項目中添加Firebase。我也跟着下面的鏈接 https://medium.com/@RICEaaron/scala-firebase-da433df93bd2#.m1fwlvc8l無法在Play框架工作應用程序中導入com.google.firebase.FirebaseApplication
我跟以下步驟
做-
在火力開發者控制檯
- 產生的私人服務器密鑰
- 創建的項目和下載的JSON文件
- 增加火力服務器SDK依賴於
build.sbt
這是我的build.sbt代碼:
name := """NeutrinoRPM"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
resolvers += Resolver.sonatypeRepo("snapshots")
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
javaCore,
"ws.securesocial" %% "securesocial" % "3.0-M3",
"org.julienrf" %% "play-jsmessages" % "1.6.2",
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.4.Final",
"mysql" % "mysql-connector-java" % "5.1.9",
"com.typesafe.play" %% "play-mailer" % "2.4.0",
"com.nimbusds" % "nimbus-jose-jwt" % "3.8.2",
"com.wordnik" %% "swagger-play2" % "1.3.12",
"org.webjars" % "swagger-ui" % "2.1.8-M1",
"com.google.api-client" % "google-api-client" % "1.21.0",
"com.google.apis" % "google-api-services-analytics" % "v3-rev127-1.21.0",
"com.google.code.gson" % "gson" % "2.6.2",
"com.google.http-client" % "google-http-client-gson" % "1.21.0",
"org.apache.pdfbox" % "pdfbox" % "2.0.1",
"com.google.firebase" % "firebase-server-sdk" % "3.0.1"
)
現在我想初始化這個代碼片斷的火力地堡服務器SDK:
FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
.build();
FirebaseApp.initializeApp(選件);
但是,當我嘗試導入
com.google.firebase.FirebaseApplication
com.google.firebase.FirebaseOptions
com.google.firebase.database
我得到這個錯誤:The import com.google.firebase.FirebaseApplication can not be resolved
我花了谷歌太多時間來解決搜索我的問題,但最終沒有幫助。請幫幫我。
(與您的問題無關)PDFBox現在是2.0.4。 –