喷涂微服务组件重复数据删除

时间:2015-06-22 23:13:55

标签: scala sbt akka spray microservices

我正在使用此模板开发微服务:

http://www.typesafe.com/activator/template/activator-service-container-tutorial

我的sbt文件是这样的:

import sbt._
import Keys._

name := "activator-service-container-tutorial"

version := "1.0.1"

scalaVersion := "2.11.6"
crossScalaVersions := Seq("2.10.5", "2.11.6")

resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases"

libraryDependencies ++= {

    val containerVersion    = "1.0.1"
  val configVersion     = "1.2.1"
  val akkaVersion           = "2.3.9"
  val liftVersion               = "2.6.2"
  val sprayVersion          = "1.3.3"

  Seq(
    "com.github.vonnagy"    %%  "service-container" % containerVersion,
    "com.github.vonnagy"    %%  "service-container-metrics-reporting" % containerVersion,
    "com.typesafe"        %   "config"                   % configVersion,
    "com.typesafe.akka"     %%  "akka-actor"                 % akkaVersion exclude ("org.scala-lang" , "scala-library"),
    "com.typesafe.akka"     %%  "akka-slf4j"                 % akkaVersion exclude ("org.slf4j", "slf4j-api") exclude ("org.scala-lang" , "scala-library"),
    "ch.qos.logback"            %   "logback-classic"        % "1.1.3",
    "io.spray"                      %%  "spray-can"                  % sprayVersion,
    "io.spray"                      %%  "spray-routing"          % sprayVersion,
    "net.liftweb"               %%  "lift-json"                  % liftVersion,

    "com.typesafe.akka"     %%  "akka-testkit"           % akkaVersion   % "test",
    "io.spray"            %%  "spray-testkit"      % sprayVersion  % "test",
    "junit"               %   "junit"              % "4.12"        % "test",
    "org.scalaz.stream"   %%  "scalaz-stream"      % "0.7a"        % "test",
    "org.specs2"          %%  "specs2-core"        % "3.5"         % "test",
    "org.specs2"          %%  "specs2-mock"        % "3.5"         % "test",
    "com.twitter"         %% "finagle-http"        % "6.25.0",
    "com.twitter"         %% "bijection-util"      % "0.7.2"
  )
}

scalacOptions ++= Seq(
  "-unchecked",
  "-deprecation",
  "-Xlint",
  "-Ywarn-dead-code",
  "-language:_",
  "-target:jvm-1.7",
  "-encoding", "UTF-8"
)

crossPaths := false

parallelExecution in Test := false


assemblyJarName in assembly := "santo.jar"
mainClass in assembly := Some("Service")

项目编译好! 但是当我进行装配时,终端会告诉我:

[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /path/.ivy2/cache/io.dropwizard.metrics/metrics-core/bundles/metrics-core-3.1.1.jar:com/codahale/metrics/ConsoleReporter$1.class
[error] /path/.ivy2/cache/com.codahale.metrics/metrics-core/bundles/metrics-core-3.0.1.jar:com/codahale/metrics/ConsoleReporter$1.class

我有什么选择来修复它? 感谢

1 个答案:

答案 0 :(得分:1)

问题似乎依赖性的传递依赖性导致了两个不同版本的metrics-core。最好的办法是使用正确的库依赖关系,以便最终得到该库的单个版本。如果难以找出依赖关系,请使用https://github.com/jrudolph/sbt-dependency-graph

如果无法访问单个版本,那么您很可能会关闭exclude route。我认为,如果所有必需版本之间存在兼容性,这只能起作用。