我想在Spark中使用第三方库(Wiremock)。但是,我得到以下异常:
Caused by: java.io.NotSerializableException:com.github.tomakehurst.wiremock.WireMockServer
Serialization stack:
- object not serializable(class:com.github.tomakehurst.wiremock.WireMockServer, value: com.github.tomakehurst.wiremock.WireMockServer@51813065)
有没有一般处理方法?
答案 0 :(得分:0)
选项很少:
com.github.tomakehurst.wiremock.WireMockServer
的子类。无需更改原始库。答案 1 :(得分:0)
您可以创建不可序列化的字段transient
。然后它就不会被序列化。
private transient WireMockServer wireMockServer;