Eclipse: Ignore “not declare static final serialVersionUID” warning

Whenever you write a Java class in Eclipse which implements java.io.Serializable interface, you’ll get this warning:

The serializable class XXXX does not declare a static final serialVersionUID field of type long

Why do we need serialVersionUID?

Whenever we implement java.io.Serializable interface, we explicitly tell JVM that this class can be serialized. Meaning, we might convert object of this class into byte streams and write it into a file or send it to another JVM through network.

Now when Java objects use serialization to save state in files, or as blobs in databases, the potential arises that the version of a class reading the data is different than the version that wrote the data.

Thus the serialVersionUID provides a versioning mechanism to Java class so that the same class format is used in reading (de-serialization) and writing (serialization) of objects.

But in most of the cases, you will not need this field. You will not have more than one versions of class file which creates issues in deserialization. And that’s why most of the time I skip adding a serialVersionUID version number.

How to ignore serialVersionUID warning

In Eclipse, you can permanently mute the serialVersionUID warning by:

1. To ignore warning for specific eclipse project:

  1. Right click on Project, select Properties from context menu (Shortcut: Alt+Enter)
  2. Go to Java Compiler > Errors/Warnings
  3. Under Potential programming problems section, change Serializable class without serialVersionUID: to Ignore

Or you may want to ignore this warning at workspace level.

2. To ignore warning at workspace level:

  1. Go to menu Windows > Preferences
  2. Navigate to Java > Compiler > Errors/Warnings
  3. Under Potential programming problems section, change Serializable class without serialVersionUID: to Ignore

View Comments

Recent Posts

  • Java

Java URL Encoder/Decoder Example

Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…

4 years ago
  • General

How to Show Multiple Examples in OpenAPI Spec

Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…

4 years ago
  • General

How to Run Local WordPress using Docker

Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…

4 years ago
  • Java

Create and Validate JWT Token in Java using JJWT

1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…

4 years ago
  • Spring Boot

Spring Boot GraphQL Subscription Realtime API

GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…

4 years ago
  • Spring Boot

Spring Boot DynamoDB Integration Test using Testcontainers

1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…

4 years ago