pureconfig 没有手动导入 pureconfig.generic.auto._

pureconfig no manual imports of pureconfig.generic.auto._

0.10.*系列pureconfig的最新更新默认禁用自动配置。

import pureconfig.generic.auto._

需要手动导入。 但是我有一个 class 层次结构,我不想每次都为 child class.

导入它
import pureconfig.ConfigReader
abstract class SparkBaseRunner[T <: Product](implicit A: ConfigReader[T])extends App {}

已经需要一个 configReader。 使用此基数时 class:

object MyOperation extends SparkBaseRunner[MyCaseClass] {}

它失败了:

could not find implicit value for parameter A: pureconfig.ConfigReader[foo.bar.my.Type]

除非在每个 child class 处手动指定上述输入。有没有办法避免这种代码重复?尝试在抽象基础 class 中指定输入对我不起作用,因为它已经需要一个 ConfigReader object.

编辑

尝试手动访问基地 class 内的配置 reader 也失败了:

implicit val configReader = deriveReader[T]
could not find implicit value for parameter A: pureconfig.ConfigReader[T]
could not find Lazy implicit value of type pureconfig.generic.DerivedConfigReader[T]

我的 Scala 版本是:2.11.12

我相信配置已经作为单个操作被读取,并且有多个应用程序都在执行以下操作:

object Ops extends SparkBaseRunner[MyCaseClass]

我看不到避免重复的方法,因为基础 class 无法推断配置,因为它只有一个通用类型 T

最好的解决办法是不用担心,使用auto._

import pureconfig.generic.auto._