英文:
SonarQube giving a "Fields in a "Serializable" class should either be transient or serializable" when class is serializable?
问题
public class ClassName implements Serializable {
private static final long serialVersionUID = 1L;
private Map<String, Object> variableName;
在上面的代码中,SonarQube 提出了 CRITICAL 级别的问题,原因是 variableName
。我知道 Object
是不可序列化的,但是否有解决办法来避免或解决这个问题呢?
英文:
public class ClassName implements Serializable {
private static final long serialVersionUID = 1L;
private Map<String, Object> variableName;
In the above code, the sonarQube is giving CRITICAL level issue because of variableName. I know Object is not serializable but do anyone have any solution to avoid or resolve this issue.
专注分享java语言的经验与见解,让所有开发者获益!
评论