【问题标题】:Why is Scala looking for SNAPSHOT version?Scala 为什么要寻找 SNAPSHOT 版本?
【发布时间】:2017-03-04 10:14:03
【问题描述】:

我提到了 json4s-native 3.3.0,但它指的是 3.3.0-SNAPSHOT。

在我的项目中有 3 个模块(通用、读取和写入),每个模块都有其 scala.sbt。

更改前:

"org.json4s" %% "json4s-native" % Versions.Json4s % "编译",

改动后:(3个模块的所有地方都改了)

“org.json4s”%%“json4s-native”%“3.3.0”%“编译”,

我跑:

sbt

干净

更新

错误:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.json4s#json4s-native_2.10;3.3.0-SNAPSHOT: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]          org.json4s:json4s-native_2.10:3.3.0-SNAPSHOT

我的Sales buld.sbt是这样的:

name := "myapp-sales"

organization in ThisBuild := "com.mycompany"

scalaVersion in ThisBuild  := "2.11.7"

//crossScalaVersions in Thisq
//Build := List("2.10.5", scalaVersion.value)
//crossPaths := false

scalacOptions in Compile in ThisBuild ++= Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-language:postfixOps", "-language:implicitConVersions")

lazy val common = Project("myapp-sales-common", file("common"))

lazy val read = Project("myapp-sales-read", file("read")).configs(IntegrationTest).settings(Defaults.itSettings: _*).dependsOn(common, write)

lazy val write = Project("myapp-sales-write", file("write")).configs(IntegrationTest).settings(Defaults.itSettings: _*).dependsOn(common)


conflictWarning in ThisBuild := ConflictWarning.disable

parallelExecution in Test in ThisBuild := false

parallelExecution in IntegrationTest in ThisBuild := false

javacOptions in Compile in ThisBuild ++= Seq("-source", "1.6", "-target", "1.6")


//Remove SNAPSHOT check from the release process (for now until Squants gets a release)
releaseProcess := releaseProcess.value.filterNot(_ == ReleaseTransformations.checkSnapshotDependencies)

我的read模块build.sbt

libraryDependencies ++= Seq(
  "com.mycompany"         %% "myapp-core-read"            % myappsales.CoreVersion            % "compile", // disable using the Scala version in output paths and artifacts,
  "com.mycompany"         %% "myapp-core-write"           % myappsales.CoreVersion            % "compile",
  "com.mycompany"         %% "myapp-registration-common"  % myappsales.RegistrationVersion    % "compile",
  "com.mycompany"         %% "myapp-load-common"          % myappsales.LoadVersion            % "compile",
  "com.mycompany"         %% "myapp-core-write-test"      % myappsales.CoreVersion            % "it, test",
  "com.mycompany"         %% "myapp-core-test"            % myappsales.CoreVersion            % "it, test"
)

libraryDependencies ++= Seq(
  "com.typesafe"               % "config"                                % myappsales.TypeSafeConfigVersion % "compile",
  "org.json4s"                 %% "json4s-native"                         % Versions.Json4s         % "compile",
  "io.spray"                    % "spray-routing"                         % Versions.Spray          % "compile",
  "com.typesafe.akka"          %% "akka-actor"                            % Versions.Akka           % "compile",
  "com.typesafe.akka"          %% "akka-remote"                           % Versions.Akka           % "compile"
    exclude ("io.netty", "netty")
)

//Assemby settings
test in assembly := {}
assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("play.api.libs.iteratee.**" -> "shade.play.api.libs.iteratee.@1")
    .inLibrary("play" % "play-iteratees_2.10" % "2.1-RC2")
    .inLibrary("org.reactivemongo" % "reactivemongo_2.10" % "0.8.1-SNAPSHOT"),
  ShadeRule.rename("scala.concurrent.stm.**" -> "shade.scala.concurrent.stm.@1")
    .inLibrary("org.scala-stm" % "scala-stm_2.10.0" % "0.6")
    .inLibrary("play" % "play-iteratees_2.10" % "2.1-RC2")
)

assemblyMergeStrategy in assembly := {
  case "application.conf" => MergeStrategy.concat
  case path => MergeStrategy.defaultMergeStrategy(path)
}

//Make assembly a publishable artifact
artifact in (
  Compile, assembly) := {
  val art = (artifact in (Compile, assembly)).value
  art.copy(`classifier` = Some("assembly"))
}

addArtifact(artifact in (Compile, assembly), assembly)

为什么它还在寻找 SNAPSHOT 版本?

【问题讨论】:

  • 你能分享你完整的 sbt 文件吗?
  • 你在哪里定义了版本对象?
  • 如果您在进行更改时已经启动了 SBT,则需要在 update 之前执行 reload
  • 感谢@AlexeyRomanov,我尝试过,但给出了同样的错误。我一个接一个地运行cleanreloadupdate

标签: scala sbt akka


【解决方案1】:

有一种相当标准的方法可以调查这类问题。在你的 plugins.sbt

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")

然后转到sbt dependencyBrowseGraph,这将打开您的浏览器并带您进入一个页面,您可以在该页面上浏览包括被驱逐的依赖关系在内的整个依赖关系图。现在找出SNAPSHOT 的来源,并通过排除将其删除。

【讨论】:

  • @Ravi 首先进入 sbt,然后在提示中输入。另外您使用的是什么版本的 SBT?
  • @Ravi 先运行sbt update,至少更新 sbt 到 0.13.6
  • 对不起我的评论,实际上,我没有放那个插件,所以我遇到了这样的问题。添加该插件后,它工作正常。
猜你喜欢
  • 2018-03-28
  • 1970-01-01
  • 2013-11-12
  • 2017-03-04
  • 2016-07-24
  • 1970-01-01
  • 2011-11-03
  • 2015-05-08
  • 1970-01-01
相关资源
最近更新 更多