2017-02-12 93 views
0

我正在使用breeze-viz 0.3,但需要使用更新版本的jfreechart。根據依賴表 https://mvnrepository.com/artifact/org.scalanlp/breeze-viz_2.10/0.3build.sbt中的強制依賴更新

jfreechart 1.0.13是默認的,但是1,0.19是更新後的版本,這是我想要的。我添加了行

dependencyOverrides ++= Set(
    "org.jfree" % "jfreechart" % "1.0.19" 
) 

並重新運行sbt eclipse,但我仍然在項目中的jfreedchart 1.0.13。我如何強制它使用1.0.19?

這裏是整個build.sbt

import AssemblyKeys._ 

name := "Simple Bayesian" 

lazy val commonSettings = Seq(
    version := "1.0", 
    organization := "com.myco", 
    scalaVersion := "2.10.4" 
) 

val sparkVersion = "2.0.0" 
val hbaseVersion = "1.0.0" 
val hadoopVersion = "2.4.0" 
val sprayVersion  = "1.3.2" 

lazy val app = (project in file(".")) 
    .settings(commonSettings: _*) 
    .settings(
    // your settings here 
) 

libraryDependencies <<= scalaVersion { 
    scala_version => Seq(
    // Spark and Spark Streaming 
    "org.apache.spark" %% "spark-core" % sparkVersion, 
    "org.apache.spark" %% "spark-mllib" % sparkVersion, 
    "org.apache.spark" %% "spark-streaming" % sparkVersion, 
    "org.apache.spark" %% "spark-streaming-kinesis-asl" % sparkVersion, 
    //"org.scalanlp" %% "breeze" % "0.12", 
    //"org.scalanlp" %% "breeze-natives" % "0.12", 
    "org.scalanlp" %% "breeze-viz" % "0.3", 
    "org.apache.commons" % "commons-lang3" % "3.3.2", 
    "org.apache.commons" % "commons-math3" %"3.2", 
    "org.apache.spark" %% "spark-hive" % sparkVersion, 
    "commons-lang" % "commons-lang" % "2.6", 
    "com.amazonaws" % "aws-java-sdk" % "1.0.002" excludeAll(ExclusionRule(organization = "javax.servlet")), 
    "org.json4s" %% "json4s-jackson" % "3.2.10", 
    "org.json4s" %% "json4s-native" % "3.2.10", 
    "com.amazonaws" % "amazon-kinesis-client" % "1.3.0", 
    "com.amazonaws" % "aws-java-sdk" % "1.9.13", 
    //"net.sf.opencsv" % "opencsv" % "2.3", 
    "log4j" % "log4j" % "1.2.17", 
    "io.spray"   %% "spray-json"  % sprayVersion, 
    //"gov.sandia.foundry" % "cognitive-foundry" % "3.4.3", 
    //"cc.mallet" % "mallet" % "2.0.8", 
    "com.github.scopt" %% "scopt" % "3.2.0"% "provided", 
    "com.github.kindlychung" % "sfreechart" % "0.1.2", 
    //"ca.umontreal.iro" % "ssj" % "2.5", 
    "joda-time" % "joda-time" % "2.3" 
) 
} 

libraryDependencies += "org.jfree" % "jfreechart" % "1.0.19" 

libraryDependencies += "org.biojava" % "jcolorbrewer" % "5.2" 

dependencyOverrides ++= Set(
// "com.fasterxml.jackson.core" % "jackson-databind" % "2.4.4" 
    "org.jfree" % "jfreechart" % "1.0.19", 
    "org.biojava" % "jcolorbrewer" % "5.2" 
) 

resolvers += "typesafe repo" at " http://repo.typesafe.com/typesafe/releases/" 
resolvers += "jitpack" at "https://jitpack.io" 

EclipseKeys.withSource := true 

我之前曾與斯卡拉2.11麻煩。我現在應該更新到2.11嗎?

+0

我的天哪。周圍沒有專家? – bhomass

+0

你可以分享你build.sbt?也,我好奇你爲什麼需要2.10依賴 – Mysterion

回答

1

您看到jfreedchart 1.0.13,但它是另一個。如果您將看到viz的依賴關係圖,您將會看到,它取決於"jfree" % "jfreechart" % "1.0.13",而您想要使用"org.jfree" % "jfreechart" % "1.0.19",它與前一個不相交,因爲它們具有不同的groupId。所以,你需要添加

libraryDependencies += "org.jfree" % "jfreechart" % "1.0.19" 

,並排除從即傳遞性依賴,是在你的classpath重複,這樣做:

libraryDependencies += "org.scalanlp" % "breeze-viz_2.10" % "0.3" exclude("jfree", "jfreechart") exclude("jfree", "jcommon") 

警告,這可能導致的問題,如果1.0.19不向下兼容1.0.13

+0

你是完全正確的。 1.0.13的組名稱爲「jfree」,但1.0.19仍被列爲更新。怎麼可能?一個具有不同組名稱的庫被作爲更新的版本給出?無論如何,這兩個版本的類名都是相同的,如果我同時擁有這兩個版本,那麼項目中仍然存在衝突。 – bhomass

+0

我已經嘗試過,並且版本衝突仍然存在,正如我所料。 – bhomass

+0

這確實是解決這個問題的方法。我想知道,如果有默認和更新版本有相同的組ID,通常是這樣。排除方法,我認爲,不適用。在這種情況下,你將如何強制它獲得更新版本? – bhomass