scala play sbt配置简单教程

时间:2016-06-17 19:44:17

标签: scala playframework sbt sorm

我正在尝试构建我的第一个播放应用。我正在关注(视频播放教程https://www.playframework.com/),但我遇到了sbt文件的问题。

sorm生成SBT版本冲突。

name := """gig"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test
)

//libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.19"

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

如果我添加以下内容,我还会收到未解决的存储库错误: libraryDependencies += "com.h2database" % "h2" % "1.3.148"

如何解决这两个问题?

编辑:

这是错误:

Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving com.typesafe.play#play-doc_2.11;1.2.2 ...
[info] Resolving org.pegdown#pegdown;1.4.0 ...
[info] Resolving org.parboiled#parboiled-java;1.1.5 ...
[info] Resolving org.parboiled#parboiled-core;1.1.5 ...
[info] Resolving org.ow2.asm#asm;4.1 ...
[info] Resolving org.ow2.asm#asm-tree;4.1 ...
[info] Resolving org.ow2.asm#asm-analysis;4.1 ...
[info] Resolving org.ow2.asm#asm-util;4.1 ...
[info] Resolving org.scala-lang#scala-compiler;2.11.7 ...
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.4 ...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[error] Modules were resolved with conflicting cross-version suffixes in {file:/Users/donbeo/Documents/scala_code/gig/}root:
[error]    org.scala-lang.modules:scala-xml _2.11, _2.12.0-M4
[error]    org.scala-lang.modules:scala-parser-combinators _2.11, _2.12.0-M4
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[error] (*:update) Conflicting cross-version suffixes in: org.scala-lang.modules:scala-xml, org.scala-lang.modules:scala-parser-combinators
[error] (*:ssExtractDependencies) Conflicting cross-version suffixes in: org.scala-lang.modules:scala-xml, org.scala-lang.modules:scala-parser-combinators
[error] Total time: 26 s, completed Jun 17, 2016 10:34:45 PM</pre><br/>See complete log in <a href="/Users/donbeo/Library/Logs/IntelliJIdea2016.1/sbt.last.log">/Users/donbeo/Library/Logs/IntelliJIdea2016.1/sbt.last.log</a>

这是播放版addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.4")

1 个答案:

答案 0 :(得分:3)

似乎sorm名为embracedependencyOverrides += "org.scala-lang" % "scala-compiler" % scalaVersion.value 依赖项正在弄乱一些事情。

由于配置错误,它总是要求scala的最后一个版本,并且因为scala 2.12“beta”已经发布,所以他要求这些。

此处描述了同样的问题:

Why do I get conflicting cross-version in sbt on one environment but not another?

要解决您的问题,您需要强制scala版本:

rm -r ~/.ivy2/cache/org.sorm-framework/sorm/

(你可以把它放在build.sbt文件的末尾)

然后我们需要清除sorm的ivy2缓存:

sbt update

现在运行

#define User MyUser

我的建议是,你可以在sorm或拥抱中打开这个问题。