gpt4 book ai didi

scala - pureconfig无法派生具有许多属性的案例类

转载 作者:行者123 更新时间:2023-12-03 05:44:00 25 4
gpt4 key购买 nike

我无法派生具有许多属性的案例类。奇怪的是,输出在SBT和Gradle之间变化。在https://github.com/geoHeil/pureconfig-issue上找到了一个最小的可重现示例,下面列出了代码:

sbt

sbt compile
[error] Caused by: java.lang.ClassNotFoundException: scala.runtime.LazyRef

摇动
./gradlew compileScala
ould not find implicit value for parameter reader: pureconfig.ConfigReader[Foo.XXX]
pureconfig.ConfigReader[XXX]

对于以下代码:
object Foo extends App {
println("here")

case class MyNestedThing(foo: String)
case class XXX(
a: String,
b: String,
c: String,
d: String,
e: String,
f: String,
g: String,
h: String,
i: String,
j: String,
k: String,
l: String,
m: String,
n: String,
o: String,
p: String,
q: String,
r: String,
s: String,
t: String,
u: String,
v: String,
w: String,
x: String,
y: String,
z: String,
aa: String,
ab: String,
ac: String,
ad: String,
ae: String,
af: String,
ag: String,
ah: String,
ai: String,
aj: String,
ak: String,
al: String,
am: String,
an: String,
ao: String,
ap: String,
aq: String,
someLonglllllllllllllllllllllllllll: String,
so1meLonglllllllllllllllllllllllllll: String,
som2eLonglllllllllllllllllllllllllll: String,
ar: MyNestedThing,
as: MyNestedThing
)

pureconfig.ConfigReader[XXX]
}

虽然在使用时可以正常工作:
object Foo extends App {
println("here")

case class MyNestedThing(foo: String)

case class XXX(
a: String,
b: String,
som2eLonglllllllllllllllllllllllllll: String,
ar: MyNestedThing,
as: MyNestedThing
)

pureconfig.ConfigReader[XXX]
}

编辑

有趣的是,我在scala版本中有一个混合,因此在将其固定为2.11 SBT时都可以正常编译,但是gradle仍然显示相同的问题。

最佳答案

当为scala编译器提供更多内存时,它可以正常工作。
https://github.com/pureconfig/pureconfig/issues/391

tasks.withType(ScalaCompile) {
configure(scalaCompileOptions.forkOptions) {
jvmArgs = ["-Xss2m"]
}
}

关于scala - pureconfig无法派生具有许多属性的案例类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51030753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com