parboiled2 和 Spray 导致跨版本后缀冲突

2024-02-02

我试图将 parboiled2 添加为我的项目的依赖项,并遵循计算器示例,但它与喷雾冲突。

我现在的build.sbt文件包括:

"io.spray" %% "spray-json" % "1.3.1" withSources() withJavadoc(),
"io.spray" %% "spray-can" % sprayV withSources() withJavadoc(),
"io.spray" %% "spray-routing" % sprayV withSources() withJavadoc(),
"io.spray" %% "spray-testkit" % sprayV  % "test" withSources() withJavadoc(),

当我添加

"org.parboiled" %% "parboiled" % "2.0.1" withSources() withJavadoc(),

I get

[error] Modules were resolved with conflicting cross-version suffixes in {file:/blar/blar}blar-blar:
[error]    com.chuusai:shapeless _2.10.4, _2.10
[error]    org.scalamacros:quasiquotes _2.10, _2.10.3
java.lang.RuntimeException: Conflicting cross-version suffixes in: com.chuusai:shapeless, org.scalamacros:quasiquotes

一些谷歌搜索也是如此,像往常一样,人们建议使用excludeSBT 指令(我认为这没有逻辑意义,因为它不可避免地会导致诸如ClassNotFoundException and NoSuchMethodError)。不过我还是尝试了一下:

"org.parboiled" %% "parboiled" % "2.0.1" withSources() withJavadoc() 
  exclude("com.chuusai", "shapeless_2.10.4") exclude("org.scalamacros", "quasiquotes_2.10")

当我尝试跑步时惊喜assembly I get

[error] java.lang.ClassNotFoundException: scala.quasiquotes.QuasiquoteCompat$

我还收到更多错误:

[error] bad symbolic reference
. A signature in RuleDSLBasics.class refers to term internal
[error] in package scala.reflect which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling RuleDSLBasics.class.
[error] error while loading RuleDSLBasics, Missing dependency 'bad symbolic reference. A signature in RuleDSLBasics.class refers to term annotations
[error] in value scala.reflect.internal which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling RuleDSLBasics.class.', required by ...

如果我注释掉 Spray 依赖项(和代码),我可以使用计算器示例成功组装一个 jar。

对于我使用 parboiled2 来说,这是一个主要的阻碍。除了还有其他办法吗exclude指令以使这些东西发挥作用?有人有 Spray 和 parboiled2 的工作构建文件吗?如果有人成功地用 onejar 或 ProGuard 解决了依赖地狱问题,如果他们能解释一下如何解决,我会很高兴的。

UPDATE:

我的构建文件:

resolvers ++= Seq(
  "Concurrent Maven Repo" at "http://conjars.org/repo",
  "spray repo" at "http://repo.spray.io"
)

val akkaV = "2.3.6"
val sprayV = "1.3.2"

libraryDependencies ++= Seq(
  "org.parboiled" %% "parboiled" % "2.0.1" withSources() withJavadoc(),
  // Causes org.scalamacros:quasiquotes _2.10, _2.10.3 cross-version problem
  "io.spray" %% "spray-testkit" % sprayV  % "test" withSources() withJavadoc(),
  // Causes com.chuusai:shapeless _2.10.4, _2.10 cross-version problem
  "io.spray" %% "spray-routing" % sprayV withSources() withJavadoc()
)

scalaVersion := "2.10.4"

javaOptions ++= Seq("-target", "1.8", "-source", "1.8")

organization := domain + "." + companyName

插件文件:

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

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

斯卡拉2.11

似乎“简单地”移动 2.11 就可以解决这个问题,但如果有一些其他库尚未准备好 2.11,那么这并不总是那么容易。尽管如此,我还是尝试了它,第二次我添加 parboiled2 作为依赖项时,它再次破坏了我的构建,叹息,这是新问题:Parboiled2 导致“加载类文件‘Prepender.class’时检测到缺少或无效的依赖项” https://stackoverflow.com/questions/27942110/parboiled2-causes-missing-or-invalid-dependency-detected-while-loading-class-fi


相同答案与 Scala 2.11 相同 https://stackoverflow.com/a/27943470/7647也应该在这里工作:替换spray-routing with spray-routing-shapeless2.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

parboiled2 和 Spray 导致跨版本后缀冲突 的相关文章

随机推荐