2017-12-18 28 views
0

我正在開發一個後端項目,第一次使用IntelliJ IDEA的Scala和Play Framework。用sbt和IntelliJ IDEA管理依賴關係

我已經讀了很多文件和主題:

我不明白如何導入依賴關係。

當我嘗試附加新的依賴項時,IntelliJ強調它並顯示「未知問題,未解決或索引」或日誌顯示並顯示「SBT未知導入」。

我添加的每個依賴項都來自Maven存儲庫。

這裏是build.sbt文件:

name := "server" 

version := "1.0" 

lazy val `server` = (project in file(".")).enablePlugins(PlayScala) 

resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases" 

resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/" 

resolvers := ("Atlassian Releases" at "https://maven.atlassian.com/public/") +: resolvers.value 

scalaVersion := "2.12.2" 

libraryDependencies ++= Seq(
    jdbc, 
    ehcache, 
    ws, 
    specs2 % Test, 
    guice, 
    "org.mongodb.scala" %% "mongo-scala-driver" % "2.1.0", 
    "com.mohiva" %% "play-silhouette" % "5.0.2", 
    "com.mohiva" %% "play-silhouette-password-bcrypt" % "5.0.2", 
    "com.mohiva" %% "play-silhouette-crypto-jca" % "5.0.2", 
    "com.mohiva" %% "play-silhouette-persistence" % "5.0.2", 
    "com.mohiva" %% "play-silhouette-testkit" % "5.0.2" % "test" 
) 

unmanagedResourceDirectories in Test <+= baseDirectory (_ /"target/web/public/test") 

回答

1

這些依賴關係是使用由播放插件定義的簡寫規定:

jdbc, 
ehcache, 
ws, 
specs2 % Test, 
guice 

因此對他們的工作,一定要在project目錄的.sbt文件中包含類似以下的行:

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.10") 

這應該解決您的問題。

特別提示:無需以下行,因爲每增加分解減慢SBT,你應該將其刪除:

resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases" 

resolvers += "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/" 

resolvers := ("Atlassian Releases" at "https://maven.atlassian.com/public/") +: resolvers.value 
+0

謝謝!我稍後再嘗試,並讓你知道 –