DSL-JSON:java.io.IOException:无法序列化提供的对象。未能找到:类的序列化程序

DSL-JSON:java.io.IOException:无法序列化提供的对象。未能找到:类的序列化程序,java,json-deserialization,json-serialization,Java,Json Deserialization,Json Serialization,我正在尝试运行其中一个示例 我得到以下错误: Exception in thread "main" java.io.IOException: Unable to serialize provided object. Failed to find serializer for: class dsl.test.Example$Model at com.dslplatform.json.DslJson.serialize(DslJson.java:2718) at dsl.test.E

我正在尝试运行其中一个示例

我得到以下错误:

Exception in thread "main" java.io.IOException: Unable to serialize provided object. Failed to find serializer for: class dsl.test.Example$Model
    at com.dslplatform.json.DslJson.serialize(DslJson.java:2718)
    at dsl.test.Example.main(Example.java:231)
我只添加了对pom.xml的依赖项:

    <dependency>
      <groupId>com.dslplatform</groupId>
      <artifactId>dsl-json</artifactId>
      <version>1.7.3</version>
    </dependency>

com.dsl平台
dsl json
1.7.3

缺少什么?

我曾经遇到过与您相同的问题,我添加此设置来解决它。您可以尝试以下方法:

DslJson<Object> json = new DslJson<>(Settings.withRuntime().allowArrayFormat(true).includeServiceLoader());
DslJson=new DslJson(Settings.withRuntime().allowArrayFormat(true.includesviceloader());

欢迎来到SO,liyixn!这里不鼓励只使用代码的答案,因为它们无法提供问题是如何解决的。请更新您的答案,并解释您的代码是如何解决当前问题的:)我也是dsl json新手,我不知道为什么它可以解决这个问题……它对我来说很有效。那么我应该删除我的答案吗?使用此
withRuntime()
设置,您已经在扼杀Dsl Json的主要优点,即编译时代码生成。现在Dsl Json将在运行时使用反射,并将影响性能,基本上将低于Gson转换器。