我正在尝试让 https://scalapb.github.io/">ScalaPB 与 Spark 一起使用。为了做到这一点,我需要使用如下代码在 SBT 中隐藏我的协议缓冲区
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("com.google.protobuf.**" -> "shadeproto.@1").inAll
)
这在 spark-shell 中不起作用。事实上,它甚至不能在 Scala REPL 中工作。下面转载的是我在 REPL 中的错误。
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.
scala> val x = zefr.commons.proto.Video.VideoProto.descriptor
error: missing or invalid dependency detected while loading class file 'VideoProto.class'.
Could not access term google in package com,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'VideoProto.class' was compiled against an incompatible version of com.
error: missing or invalid dependency detected while loading class file 'VideoProto.class'.
Could not access term protobuf in value com.google,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'VideoProto.class' was compiled against an incompatible version of com.google.
error: missing or invalid dependency detected while loading class file 'GeneratedMessageCompanion.class'.
Could not access term google in package com,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'GeneratedMessageCompanion.class' was compiled against an incompatible version of com.
error: missing or invalid dependency detected while loading class file 'GeneratedMessageCompanion.class'.
Could not access term protobuf in value com.google,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'GeneratedMessageCompanion.class' was compiled against an incompatible version of com.google.
error: missing or invalid dependency detected while loading class file 'VideoProto.class'.
Could not access term Descriptors in value com.protobuf,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'VideoProto.class' was compiled against an incompatible version of com.protobuf.
error: missing or invalid dependency detected while loading class file 'VideoProto.class'.
Could not access term protobuf in value com.google,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'VideoProto.class' was compiled against an incompatible version of com.google.
error: missing or invalid dependency detected while loading class file 'VideoProto.class'.
Could not access term google in package com,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'VideoProto.class' was compiled against an incompatible version of com.
error: missing or invalid dependency detected while loading class file 'VideoProto.class'.
Could not access type Descriptor in value com.Descriptors,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'VideoProto.class' was compiled against an incompatible version of com.Descriptors.
这是我的 build.sbt 文件的完整副本
scalaVersion := "2.11.8"
organization := "zefr.commons"
name := "commons-proto"
val nexus = "http://nexus.zefr.com/repository/maven"
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots"),
"Neuxs Snapshots" at s"$nexus-snapshots",
"Neuxs Releases" at s"$nexus-releases"
)
conflictManager := ConflictManager.strict
PB.targets in Compile := Seq(
scalapb.gen() -> (sourceManaged in Compile).value
)
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("com.google.protobuf.**" -> "shadeproto.@1").inAll
)
和项目/protos.sbt
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.3")
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.5.45-p3"
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
谁能帮我理解我在这里缺少什么?
谢谢
编辑
为了看看这是否是我要介绍的问题,我下载了这个项目并按原样构建它,只是将 Scala 版本更改为 2.11.8,我得到了同样的错误。
scala> val x = com.example.protos.demo.Person.descriptor
error: missing or invalid dependency detected while loading class file 'Person.class'.
Could not access term google in package com,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.
error: missing or invalid dependency detected while loading class file 'Person.class'.
Could not access term protobuf in value com.google,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.google.
error: missing or invalid dependency detected while loading class file 'GeneratedMessageCompanion.class'.
Could not access term google in package com,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'GeneratedMessageCompanion.class' was compiled against an incompatible version of com.
error: missing or invalid dependency detected while loading class file 'GeneratedMessageCompanion.class'.
Could not access term protobuf in value com.google,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'GeneratedMessageCompanion.class' was compiled against an incompatible version of com.google.
error: missing or invalid dependency detected while loading class file 'Person.class'.
Could not access term Descriptors in value com.protobuf,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.protobuf.
error: missing or invalid dependency detected while loading class file 'Person.class'.
Could not access term protobuf in value com.google,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.google.
error: missing or invalid dependency detected while loading class file 'Person.class'.
Could not access term google in package com,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.
error: missing or invalid dependency detected while loading class file 'Person.class'.
Could not access type Descriptor in value com.Descriptors,
because it (or its dependencies) are missing. Check your build definition for
missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.Descriptors.