使用 sbt 添加 slick 依赖时出错
Error while adding slick dependency using sbt
我是 scala 世界的新手(来自 android 世界),我已经使用游戏框架创建了 scala 项目,一切正常,现在我需要添加数据库,为此我决定选择 slick,但是当我试图添加这样的依赖时
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
我收到此错误日志
Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving com.typesafe#jse_2.10;1.2.3 ...
[info] Resolving org.scala-sbt#run;0.13.15 ...
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-48dd0744422128446aee9ac31aa356ee203cc9f4 ...
[info] Resolving com.typesafe.play#play-exceptions;2.6.5 ...
[info] Resolving org.scala-sbt#test-interface;1.0 ...
[info] Resolving com.jcraft#jsch;0.1.50 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
[info] Resolving jline#jline;2.14.3 ...
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.13.15 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.13.15 ...
[info] Resolving org.scala-sbt#logic;0.13.15 ...
[info] Resolving com.typesafe#config;1.3.1 ...
[info] Resolving org.scala-sbt#main-settings;0.13.15 ...
[info] Resolving com.lightbend.play#play-file-watch_2.10;1.0.0 ...
[info] Resolving com.typesafe.play#sbt-plugin;2.6.5 ...
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.typesafe.slick#slick_2.12;3.1.0: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.slick#slick_2.12;3.1.0: not found
[error] Total time: 4 s, completed Sep 28, 2017 12:21:57 PM</pre><br/>See complete log in <a href="file:/home/dev-00/.IntelliJIdea2017.1/system/log/sbt.last.log">file:/home/dev-00/.IntelliJIdea2017.1/system/log/sbt.last.log</a>
这是我的洞 sbt 构建脚本
name := """play-scala-starter-example"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
resolvers += Resolver.sonatypeRepo("snapshots")
scalaVersion := "2.12.2"
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
libraryDependencies ++= Seq(
jdbc,
"com.typesafe.play" %% "anorm" % "2.5.3"
)
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test
libraryDependencies += "com.h2database" % "h2" % "1.4.194"
libraryDependencies += jdbc
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.41"
将以下行添加到您的 build.sbt
resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/releases/"
根据我在 maven 上的发现,似乎只有少数几个版本的 slick 是针对 scala 2.12 编译的:
- 3.2.1
- 3.2.0
- 2.1.0
使用更新版本的 slick 或其他 scala 版本 (2.11.x)。
我是 scala 世界的新手(来自 android 世界),我已经使用游戏框架创建了 scala 项目,一切正常,现在我需要添加数据库,为此我决定选择 slick,但是当我试图添加这样的依赖时
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
我收到此错误日志
Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving com.typesafe#jse_2.10;1.2.3 ...
[info] Resolving org.scala-sbt#run;0.13.15 ...
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-48dd0744422128446aee9ac31aa356ee203cc9f4 ...
[info] Resolving com.typesafe.play#play-exceptions;2.6.5 ...
[info] Resolving org.scala-sbt#test-interface;1.0 ...
[info] Resolving com.jcraft#jsch;0.1.50 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
[info] Resolving jline#jline;2.14.3 ...
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.13.15 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.13.15 ...
[info] Resolving org.scala-sbt#logic;0.13.15 ...
[info] Resolving com.typesafe#config;1.3.1 ...
[info] Resolving org.scala-sbt#main-settings;0.13.15 ...
[info] Resolving com.lightbend.play#play-file-watch_2.10;1.0.0 ...
[info] Resolving com.typesafe.play#sbt-plugin;2.6.5 ...
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.typesafe.slick#slick_2.12;3.1.0: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.slick#slick_2.12;3.1.0: not found
[error] Total time: 4 s, completed Sep 28, 2017 12:21:57 PM</pre><br/>See complete log in <a href="file:/home/dev-00/.IntelliJIdea2017.1/system/log/sbt.last.log">file:/home/dev-00/.IntelliJIdea2017.1/system/log/sbt.last.log</a>
这是我的洞 sbt 构建脚本
name := """play-scala-starter-example"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
resolvers += Resolver.sonatypeRepo("snapshots")
scalaVersion := "2.12.2"
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
libraryDependencies ++= Seq(
jdbc,
"com.typesafe.play" %% "anorm" % "2.5.3"
)
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test
libraryDependencies += "com.h2database" % "h2" % "1.4.194"
libraryDependencies += jdbc
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.41"
将以下行添加到您的 build.sbt
resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/releases/"
根据我在 maven 上的发现,似乎只有少数几个版本的 slick 是针对 scala 2.12 编译的:
- 3.2.1
- 3.2.0
- 2.1.0
使用更新版本的 slick 或其他 scala 版本 (2.11.x)。