2015-06-22 41 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