Where do I change the setting in Eclipse so that it would generate serialVersionUID for Serializable classes?

非 Y 不嫁゛ 提交于 2019-12-20 03:17:29

问题


I want Eclipse to generate a serialVersionUID for classes that implement Serializable.

However, my Eclipse instance does not throw me a warning or an error when I create a class that implements Serializable. Also, it does not give an suggestion about adding a generated serialVersionUID. Where do I change the required setting?


回答1:


To turn on warning for Serializable class without a serialVersionID, go to Window > Preference > Java > Compiler > Errors/Warnings and search for Serializable class without a serialVersionID. Set that to Error or Warning based on your preference.

Once warning for "[class] does not declare a static final serialVersionUID field of type long" are thrown you can click on the serialization class and press CTRL + 1.



来源:https://stackoverflow.com/questions/12102269/where-do-i-change-the-setting-in-eclipse-so-that-it-would-generate-serialversion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!