[英]Serializable Object.class
public class RegisterRequest implements Serializable {
@NotNull(message = "Register may not be null")
private Object register;
}
I got codeSmell from sonarLing SonarLint: Make "data" transient or serializable.
我从 sonarLing
SonarLint: Make "data" transient or serializable.
得到了 codeSmell SonarLint: Make "data" transient or serializable.
Because I have Object.class
I can't add in this class implements Serializable
also I can't transient
because I need this object serialize.因为我有
Object.class
我不能在这个类中添加implements Serializable
也我不能transient
因为我需要这个对象序列化。
How I can fix this codeSmeel by sonar lint?我如何通过声纳棉绒修复此代码?
The thing with Object fields is, those do not implement the Serializable
interface.对象字段的问题是,那些不实现
Serializable
接口。 SonarQube is saying that you're trying to serialize a field, in this case Object register
which does not implement the interface. SonarQube 是说您正在尝试序列化一个字段,在这种情况下是未实现接口的
Object register
。 For your register
field you should use a custom class which implements the Serializable
interface.对于您的
register
字段,您应该使用实现Serializable
接口的自定义类。
Because of this SonarQube is telling you that you should either let Object
implement the Serializable
interface (which you can't) or mark it with transient
.因为这个 SonarQube 告诉你,你应该让
Object
实现Serializable
接口(你不能)或用transient
标记它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.