我正在使用Scala和使用IntelliJ IDEA的Play Framework首次使用后端项目。
我一直在阅读很多文档和主题:
我无法理解如何导入依赖项。
当我尝试追加新的依赖项时,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" )
答案 0 :(得分:1)
这些依赖项是使用Play插件定义的简写指定的:
jdbc,
ehcache,
ws,
specs2 % Test,
guice
因此,要让它们工作,请确保在.sbt
目录的project
文件中包含如下所示的行:
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