用sbt和IntelliJ IDEA管理依赖关系

我正在开发一个后端项目,第一次使用IntelliJ IDEA的Scala和Play Framework。用sbt和IntelliJ IDEA管理依赖关系

我已经读了很多文件和主题:

  • SBT Library dependencies doc
  • IntelliJ support post
  • Another post从计算器

我不明白如何导入依赖关系。

当我尝试附加新的依赖项时,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")

回答:

这些依赖关系是使用由播放插件定义的简写规定:

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

以上是 用sbt和IntelliJ IDEA管理依赖关系 的全部内容, 来源链接: utcz.com/qa/262893.html

回到顶部