Eclipse auto-generation of serialVersionUID with each change

前端 未结 3 1463
[愿得一人]
[愿得一人] 2021-01-04 04:52

Eclipse nicely generates the serialVersionUID for me. But this seems to be passive code generation as the id won\'t be automatically updated as I change the file unless I do

3条回答
  •  感情败类
    2021-01-04 05:37

    the id won't be automatically updated as I change the file unless I do the generation again.

    AFAIK default serialVersionUID is just this -- an id generated based on current "shape" of a class. So if you want your id generated when you change anything -- just leave it out.

    However, if you want to change serialVersionUID only sometimes -- just change it. Random modification to the id will do.

    Random number is only little better than consecutive numbers (if you can assume no one else makes up a class with the same qualified name in your environment), so you may even start from serialVersionUID = 1 and increment this number at will.

提交回复
热议问题