scala 如何解决sbt java.lang.RuntimeException:在库依赖项中发现版本冲突;有些被怀疑是二进制不兼容的:

col17t5w  于 2023-10-18  发布在  Scala
关注(0)|答案(1)|浏览(117)

我已经升级了我的sbt版本到sbt 1.9.0这里是我的插件。sbt

resolvers += Classpaths.typesafeReleases
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")

addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.1.1")

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

libraryDependencies += "ai.kien" %% "python-native-libs" % "0.2.2"

这是我的建筑。

import com.typesafe.sbt.packager.docker.{DockerChmodType, DockerPermissionStrategy, ExecCmd}
import ai.kien.python.Python

lazy val root = (project in file("."))
  .settings(
    name := "notary-scraping"
  )

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "2.13.1"

ThisBuild / scapegoatVersion := "1.4.0"

enablePlugins(JavaAppPackaging, DockerPlugin)

packageName in Docker:= "myproject"
dockerBaseImage := "amazoncorretto:11-alpine3.18-jdk"

version in Docker:= "0.0.1"
dockerExposedPorts:= Seq(8083)

dockerChmodType := DockerChmodType.UserGroupWriteExecute
dockerPermissionStrategy := DockerPermissionStrategy.CopyChown
dockerAdditionalPermissions += (DockerChmodType.UserGroupPlusExecute, "/var/run/")
daemonUserUid in Docker := None
daemonUser in Docker    := "root"

dockerBaseImage := "amazoncorretto:11-alpine3.18-jdk"

fork := true

lazy val python = Python("/usr/bin/python3")

lazy val javaOpts = python.scalapyProperties.get.map {
  case (k, v) => s"""-D$k=$v"""
}.toSeq

javaOptions ++= javaOpts

libraryDependencies ++= Seq(
  "org.jsoup" % "jsoup" % "1.15.3",
  "net.ruippeixotog" %% "scala-scraper" % "3.0.0",
  "com.typesafe" % "config" % "1.3.0",
  "com.typesafe.akka" %% "akka-actor" % "2.6.0",
  "com.typesafe.akka" %% "akka-stream" % "2.7.0",
  "com.typesafe.akka" %% "akka-http" % "10.5.0",
  "ch.qos.logback" % "logback-classic" % "1.3.5",
  "com.typesafe.akka" %% "akka-http-spray-json" % "10.5.0",
  "com.google.inject" % "guice" % "5.1.0",
  "com.typesafe.akka" %% "akka-stream-testkit" % "2.7.0",
  "com.typesafe.akka" %% "akka-http-testkit" % "10.5.0",
  "org.scalatest" %% "scalatest" % "3.2.11",
  "com.outworkers" %% "phantom-dsl" % "2.59.0",
  "com.opencsv" % "opencsv" % "5.7.1",
  "org.rauschig" % "jarchivelib" % "0.7.1",
  "io.netty" % "netty-transport-native-epoll" % "4.1.79.Final" classifier "linux-x86_64",
  "org.apache.poi" % "poi" % "5.0.0",
  "org.seleniumhq.selenium" % "selenium-devtools-v117" % "4.13.0",
  "org.seleniumhq.selenium"% "selenium-java"% "4.13.0",
  "org.apache.poi" % "poi-ooxml" % "5.0.0",
  "me.shadaj" %% "scalapy-core" % "0.5.2"
)

这是我得到的例外

ava.lang.RuntimeException: found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[error] 
[error]     * org.scala-lang.modules:scala-xml_2.12:2.1.0 (early-semver) is selected over 1.0.6
[error]         +- com.github.sbt:sbt-native-packager:1.9.16 (sbtVersion=1.0, scalaVersion=2.12) (depends on 2.1.0)
[error]         +- org.scalariform:scalariform_2.12:0.2.0             (depends on 1.0.6)
[error] 
[error] 
[error] this can be overridden using libraryDependencySchemes or evictionErrorLevel
[error]     at scala.sys.package$.error(package.scala:30)
rhfm7lfc

rhfm7lfc1#

这是一个已知的问题:Consider bumping scala-compiler's scala-xml dependency to 2.x in Scala 2.12。您可以按照问题描述中的建议解决错误。
在文件project/plugins.sbt中添加

ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

相关问题