【问题标题】:Play JSON library and sbt assembly merge error播放 JSON 库和 sbt 程序集合并错误
【发布时间】:2020-05-23 15:52:08
【问题描述】:

即使使用简单的 Hello 程序,如果我将 play-json 作为库依赖项添加到 build.sbt 文件中,当我在 sbt (sbt-assembly plugin )。

[error] stack trace is suppressed; run last assembly for the full output
[error] (assembly) deduplicate: different file contents found in the following:
[error] /home/heitor/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.jar:module-info.class
[error] /home/heitor/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.jar:module-info.class
[error] /home/heitor/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.jar:module-info.class
[error] /home/heitor/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.10.1/jackson-datatype-jdk8-2.10.1.jar:module-info.class
[error] /home/heitor/.cache/coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.10.1/jackson-datatype-jsr310-2.10.1.jar:module-info.class

MergeApp.scala

object MergeApp extends App {
  println("Hello")
}

build.sbt

name := "MergeBug"

version := "0.1"

scalaVersion := "2.13.1"

val playJsonVersion = "2.8.1"

libraryDependencies ++= Seq("com.typesafe.play" %% "play-json" % playJsonVersion)

项目/build.properties

sbt.version = 1.3.8

项目/plugins.sbt

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")

【问题讨论】:

    标签: scala merge sbt-assembly play-json


    【解决方案1】:

    您需要定义自定义合并策略。见https://github.com/sbt/sbt-assembly#merge-strategy

    由于module-info.class 文件仅对 Java 9+ 模块有用,您可以放心地丢弃它们:

    assemblyMergeStrategy in assembly := {
      case "module-info.class" => MergeStrategy.discard
      case x =>
        val oldStrategy = (assemblyMergeStrategy in assembly).value
        oldStrategy(x)
    }
    

    【讨论】:

    • @RobertSchneider 您的情况可能有所不同。也许问一个新问题?
    猜你喜欢
    • 2018-08-19
    • 2013-08-02
    • 1970-01-01
    • 2016-09-02
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 2014-02-10
    相关资源
    最近更新 更多