English 中文(简体)
每一组 Java类需要不同的独一无二的序列版ID?
原标题:Does each Java class in an app need to have a different unique serial version ID?

从我在线读到,为某类人制作一个序列版的身份证似乎是一种良好做法。

我的问题是,在申请中,我是否必须为每一类人建立一个独特的身份证?

Or can I simply assign the following ID to each class in my application?

<条码> 自动终端终端终端序列VersionUID = 1;

最佳回答
  • You only need a serial version ID for classes that will be serialized, i.e. mostly those that implement Serializable
  • The ID is per class, it s not a problem if two classes have the same
  • It s only necessary if there is a chance that serialized instances will be deserialized by a different version of the program. This is often not the case.
问题回答

无,它就特定类别而言,并不重要,而是按序版(for该类别>)。 班级名称本身仍按序排列,因此,在all各班之间不必独一无二。 (当然,你可<>>找到其他办法,使每一类的版本数目不同。) 我可以直截了当,但这是一个不同的问题。

使用固定价值是罚款,但do <>/em>需要确保你在你真正改变序列化格式(例如增加一个领域)时改变这一格式。

Mind you, I d prefer to use something like Protocol Buffers which is rather more graceful with backward/forward compatibility :)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...