I want to use a 3rd party library(Wiremock) with Spark. However, I get the following exception:
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)
Is there a general way to deal with this?
There are few options:
com.github.tomakehurst.wiremock.WireMockServer
. No need to change the original library. You can make the field that is not serializable transient
. Then it will just not be serialized.
private transient WireMockServer wireMockServer;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.