2015-06-22 60 views
0

我使用這個模板來開發微服務:噴霧微服務組件進行重複數據刪除

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

這個問題,因爲它似乎依賴關係的傳遞依賴是由兩個不同版本的metrics-core產生的。最好的辦法是使用正確的庫依賴關係,以便最終獲得該庫的單個版本。如果很難弄清楚依賴關係,請使用https://github.com/jrudolph/sbt-dependency-graph

如果無法獲得單一版本,那麼您最有可能倒下exclude route。我認爲,這是唯一的工作,如果所有需要的版本之間兼容。

+0

sbt-dependency-graph顯示此:https://gist.githubusercontent.com/hectorgool/6616dadc0993672d2194/raw/71393a3ca0b6e355154a649e507a7b78cfa9861a/out – Sanx

+0

解決! 「com.goda.vonnagy」\t %%「service-container-metrics-reporting」%containerVersion exclude(「com.codahale.metrics」,「metrics-core」), – Sanx