我有一个sbt项目,该项目配置有Dependencias.scala
、build.sbt
和plugins.sbt
,并且我具有以下依赖关系:https://christopherdavenport.github.io/cormorant/
lazy val `cormorant-core` = "io.chrisdavenport" %% "cormorant-core" % Version.cormorant
lazy val `cormorant-generic` = "io.chrisdavenport" %% "cormorant-generic" % Version.cormorant
lazy val `cormorant-parser` = "io.chrisdavenport" %% "cormorant-parser" % Version.cormorant
lazy val `cormorant-http4s` = "io.chrisdavenport" %% "cormorant-http4s" % Version.cormorant
lazy val `cormorant-refined` = "io.chrisdavenport" %% "cormorant-refined" % Version.cormorant
当我编译它时:sbt-compile,它出现了这个错误:
[error] /home/javier/IdeaProjects/ERPFetcherJavs/src/main/scala/com/arkondata/bipo/utils/CSVHandler.scala:11:53: could not find implicit value for parameter gen: shapeless.LabelledGeneric.Aux[A,H]
[error] private implicit val lr: LabelledRead[ItemData] = deriveLabelledRead
[error] ^
[error] /home/javier/IdeaProjects/ERPFetcherJavs/src/main/scala/com/arkondata/bipo/utils/CSVHandler.scala:13:54: could not find implicit value for parameter gen: shapeless.LabelledGeneric.Aux[A,H]
[error] private implicit val lw: LabelledWrite[ItemData] = deriveLabelledWrite
[error] ^
[error] two errors found
[error] (Compile / compileIncremental) Compilation failed
我该怎么修??
假设ItemData
是一个简单的case类,例如:
case class ItemData(a: String)
然后,当运行上面的代码时,上面的错误会再次出现。为什么会发生这种情况?
deriveLabelledRead
是package io.chrisdavenport.cormorant.generic
的一种方法,它包含两个隐含项:
def deriveLabelledRead[A, H <: HList](
implicit gen: LabelledGeneric.Aux[A, H],
hlw: Lazy[LabelledRead[H]])
在阅读了文档后,我们需要做一堆导入:
import io.chrisdavenport.cormorant._
import io.chrisdavenport.cormorant.generic.semiauto._
import io.chrisdavenport.cormorant.parser._
import io.chrisdavenport.cormorant.implicits._
import cats.implicits._
import java.util.UUID
import java.time.Instant
导入这些内容时,deriveLabelledRead
具有正确创建所需的隐含项。