@avrorecord在scala中没有解析scalamacro插件

f0ofjuux  于 2021-06-07  发布在  Kafka
关注(0)|答案(0)|浏览(232)

我正在尝试将它们与avroschema集成,以将消息编码/解码为case类scala。我使用的是scala版本2.10.4和库“com.julianpeeters”%”avro-scale-macro-annotations\u 2.10“%”“0.4.9”。在build.sbt中我添加了这个插件来完成,但不幸的是没有解析addcompilerplugin(“org.scalamacros“%”paradise“%”2.1.0“cross crossversion.full)。我阅读了许多指南,其中简单地说要在ide中手工添加开发(在我的例子中是intellij)。不幸的是,我已经完成了这个解决方案,但没有成功。我总是犯错误,让你回来。

[error] 
[error]   last tree to typer: Ident(String)
[error]               symbol: <none> (flags: )
[error]    symbol definition: <none>
[error]        symbol owners: 
[error]       context owners: package domain
[error] 
[error] == Enclosing template or block ==
[error] 
[error] Import(
[error]   "com"."julianpeeters"."avro"."annotations"
[error]   List(
[error]     ImportSelector(AvroRecord,81,AvroRecord,81)
[error]   )
[error] )
[error] 
[error] no-symbol does not have an owner
[error]     at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)
[error]     at scala.tools.nsc.Global.abort(Global.scala:254)
[error]     at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3257)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedTypeDefImpl(Typers.scala:2318)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typedTypeDef(Typers.scala:2298)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5585)
[error]     at org.scalamacros.paradise.typechecker.Analyzer$$anon$1.org$scalamacros$paradise$typechecker$Typers$ParadiseTyper$$super$typed1(Analyzer.scala:19)
[error]     at org.scalamacros.paradise.typechecker.Typers$ParadiseTyper$class.typed1(Typers.scala:44)
[error]     at org.scalamacros.paradise.typechecker.Analyzer$$anon$1.typed1(Analyzer.scala:19)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5642)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$typeCheck$2$$anonfun$5.apply(Typers.scala:25)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$typeCheck$2$$anonfun$5.apply(Typers.scala:25)
[error]     at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:727)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$typeCheck$2.apply(Typers.scala:25)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$typeCheck$2.apply(Typers.scala:25)
[error]     at scala.tools.nsc.typechecker.Contexts$Context.withMacrosEnabled(Contexts.scala:242)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$3.apply(Typers.scala:18)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$3.apply(Typers.scala:18)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$wrapper$1$1.apply(Typers.scala:19)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$wrapper$1$1.apply(Typers.scala:19)
[error]     at scala.tools.nsc.typechecker.Contexts$Context.withImplicitsEnabled(Contexts.scala:211)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$1.apply(Typers.scala:17)
[error]     at scala.reflect.macros.runtime.Typers$$anonfun$1.apply(Typers.scala:17)
[error]     at scala.reflect.macros.runtime.Typers$class.wrapper$1(Typers.scala:19)
[error]     at scala.reflect.macros.runtime.Typers$class.typeCheck(Typers.scala:25)
[error]     at scala.reflect.macros.runtime.Context.typeCheck(Context.scala:6)
[error]     at scala.reflect.macros.runtime.Context.typeCheck(Context.scala:6)
[error]     at com.julianpeeters.avro.annotations.AvroRecordMacro$$anonfun$indexFields$1$1.apply(AvroRecordMacro.scala:228)
[error]     at com.julianpeeters.avro.annotations.AvroRecordMacro$$anonfun$indexFields$1$1.apply(AvroRecordMacro.scala:226)
[error]     at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
[error]     at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
[error]     at scala.collection.immutable.List.foreach(List.scala:318)
[error]     at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
[error]     at scala.collection.AbstractTraversable.map(Traversable.scala:105)
[error]     at com.julianpeeters.avro.annotations.AvroRecordMacro$.indexFields$1(AvroRecordMacro.scala:226)
[error]     at com.julianpeeters.avro.annotations.AvroRecordMacro$.impl(AvroRecordMacro.scala:238)
[error] @AvroRecord
[error]  ^

my build.sbt的片段:

scalaVersion := "2.10.4"
resolvers ++= Seq(
  Resolver.sonatypeRepo("releases"),
  "typesafe-repository" at "http://repo.typesafe.com/typesafe/releases/",
  "clojars-repository" at "https://clojars.org/repo"
)
libraryDependencies ++= Seq(
...
  "com.julianpeeters" % "avro-scala-macro-annotations_2.10" % "0.4.9",
  "com.fasterxml.jackson.dataformat" % "jackson-dataformat-smile" % "2.2.3"
)

最后是无法解决的问题:

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题