Scalaxb忽略未知字段

时间:2019-02-22 04:50:00

标签: scala scalaxb sbt-scalaxb

当您的服务器添加了新字段以进行响应时,如果我们不让scalaxb知道忽略未知字段(例如,杰克逊中的@JsonIgnore),则客户端将失败。

1 个答案:

答案 0 :(得分:0)

为此,它有一个非常好的解决方案。只需在构建工具的build.sbt示例代码中的(Compile,scalaxb):= true中添加scalaxbIgnoreUnknown

```lazy val helloModule = (project in file(".")).settings(
commonSettings,
publishSetting,
scalaxbIgnoreUnknown in (Compile, scalaxb) := true,
scalaxbDispatchVersion in (Compile, scalaxb) := vDispatch,
scalaxbPackageName in (Compile, scalaxb)     := "com.hello.helloModule.client",
libraryDependencies := Seq(
      "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4",
      "org.scala-lang.modules" %% "scala-swing" % "2.0.0-M2",


      "net.databinder.dispatch" %% "dispatch-core" % vDispatch,
      "com.typesafe" % "config" % "1.3.1",
  "org.scala-lang.modules" %% "scala-xml" % "1.1.0"
    ),
name := "com.hello.helloModule.client").enablePlugins(ScalaxbPlugin)```