移动 class 包时抛出可序列化 class 未找到 CLASSNAME 错误(即使认为 serialVersionUID 在 class 中说明)
Serializable class not found CLASSNAME error is thrown when moving class package(even thought serialVersionUID is stated in class)
我正在使用 Redis(通过 redisson)我有一个 DTO class 我正在序列化一个反序列化到 Redis,
我使用的编解码器是:
org.redisson.codec.FstCodec
尽管在 class 中的 DTO class 中明确设置了 serialVersionUID,但当我将 class 移动到不同的命名空间时,我得到以下异常:
java.io.IOException: java.lang.RuntimeException: class not found CLASSNAME:db.data.coins.CoinDTO loader:jdk.internal.loader.ClassLoaders$AppClassLoader@6ed3ef1
在示例中,我从包中移动了 class:
db.data.coins.CoinDTO
打包:
dto
Link 到 fstCodec github:
package dto; // altering package
import java.io.Serializable;
import java.sql.Timestamp;
public class CoinDTO implements Serializable {
static final long serialVersionUID = 1L;
private int id;
private double amount;
private Timestamp timestamp;
//Getters and setters
}
我想更改包并仍然从 Redis 获得 class。
非常感谢
P.S
我目前处理它的方式是使用json序列化对象,然后将其设置到redis中,但这只是双重序列化,我想避免这种情况
when I move the class to a diffrent namespace despite setting the: serialVersionUID explicitly in the DTO class in class I get the following exception:
如果对象的包或 class 名称已更改,则无法反序列化对象。
The way I am currently handling it is by serializing of the object using json and then setting it into redis
您可以将 Redisson 设置为 Jackson,如下所示 codec = org.redisson.codec.JsonJacksonCodec
我正在使用 Redis(通过 redisson)我有一个 DTO class 我正在序列化一个反序列化到 Redis,
我使用的编解码器是:
org.redisson.codec.FstCodec
尽管在 class 中的 DTO class 中明确设置了 serialVersionUID,但当我将 class 移动到不同的命名空间时,我得到以下异常:
java.io.IOException: java.lang.RuntimeException: class not found CLASSNAME:db.data.coins.CoinDTO loader:jdk.internal.loader.ClassLoaders$AppClassLoader@6ed3ef1
在示例中,我从包中移动了 class:
db.data.coins.CoinDTO
打包:
dto
Link 到 fstCodec github:
package dto; // altering package
import java.io.Serializable;
import java.sql.Timestamp;
public class CoinDTO implements Serializable {
static final long serialVersionUID = 1L;
private int id;
private double amount;
private Timestamp timestamp;
//Getters and setters
}
我想更改包并仍然从 Redis 获得 class。
非常感谢
P.S
我目前处理它的方式是使用json序列化对象,然后将其设置到redis中,但这只是双重序列化,我想避免这种情况
when I move the class to a diffrent namespace despite setting the: serialVersionUID explicitly in the DTO class in class I get the following exception:
如果对象的包或 class 名称已更改,则无法反序列化对象。
The way I am currently handling it is by serializing of the object using json and then setting it into redis
您可以将 Redisson 设置为 Jackson,如下所示 codec = org.redisson.codec.JsonJacksonCodec