在scala中使用PureConfig和Circe时出现Shapeless错误


shapeless.DefaultSymbolicLabelling  
shapeless.DefaultSymbolicLabelling$.instance(shapeless.HList)

在同时使用pureconfigcirce时得到此错误。我使用spark 3.1.2与spark k8s操作符。

此错误是由于无形状库版本冲突造成的。Spark 3.1.2附带了shaeless 2.3.3,而这两个包都需要shaeless 2.3.7。为了解决这个问题,我遵循了这里提到的步骤,包括重命名依赖项。

为SBT

如果你正在使用sbt-assembly插件来创建jar,你可以通过添加到你的程序集来遮蔽无形状。SBT文件以下设置:

assembly / assemblyShadeRules := Seq(ShadeRule.rename("shapeless.**" -> "new_shapeless.@1").inAll)

Maven > maven-shade-plugin可以通过在你的pom.xml文件中添加下面的代码块来实现无形状的阴影:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <createDependencyReducedPom>false</createDependencyReducedPom>
        <relocations>
            <relocation>
                <pattern>shapeless</pattern>
                <shadedPattern>shapelesspureconfig</shadedPattern>
            </relocation>
        </relocations>
    </configuration>
</plugin>

最新更新