This section summarizes the configuration of serialization options, explained in the above sections, into all-in-one examples. The following are example serialization configurations.
<hazelcast>
    <serialization>
        <allow-override-default-serializers>true</allow-override-default-serializers>
    </serialization>
</hazelcast>hazelcast:
    serialization:
        allow-override-default-serializers: trueSerializationConfig{
  boolean isAllowOverrideDefaultSerializers();
  SerializationConfig setAllowOverrideDefaultSerializers(final boolean allowOverrideDefaultSerializers);}Configuration Options
Use these configuration options to configure serialization:
| Deprecation Notice for Portable Serialization Portable Serialization has been deprecated. We recommend you use Compact Serialization as Portable Serialization will be removed as of version 7.0. | 
| Option | Description | Default | 
|---|---|---|
| 
 | Defines the version of a portable serialization implementation. A portable version differentiates two of the same classes that have differ such as those that have different fields or different field types. | 
 | 
| 
 | Whether to use the native byte order of the underlying platform. | 
 | 
| 
 | Defines the byte order that the serialization uses:  | 
 | 
| 
 | Enables compression if the default Java serialization is used. | 
 | 
| 
 | Enables shared object if the default Java serialization is used. | 
 | 
| 
 | Whether to allow  | 
 | 
| 
 | Whether to allow built-in serializers to be overridden. | 
 | 
| 
 | Registers a class that implements
 | |
| 
 | Registers a  | |
| 
 | Registers a global serializer class to be used when no other serializer is available.
This element has the optional boolean attribute  | |
| 
 | The class name of the custom serializer implementation. See Custom Serialization | |
| 
 | Whether to check for class definition errors at startup and throw a serialization exception with an error definition. | |
| 
 | Provides deserialization protection based on whitelisting and blacklisting the class/package names. | |
| 
 | Provides ways to enable Compact serialization and register explicit or reflective compact serializers for classes. See CompactSerializationConfig section for details. | 
Full Example of Serialization Configuration
The following are example configuration settings for various serializers.
<hazelcast>
    <serialization>
        <portable-version>0</portable-version>
        <use-native-byte-order>false</use-native-byte-order>
        <byte-order>BIG_ENDIAN</byte-order>
        <data-serializable-factories>
            <data-serializable-factory factory-id="1">com.hazelcast.examples.DataSerializableFactory
            </data-serializable-factory>
        </data-serializable-factories>
        <portable-factories>
            <portable-factory factory-id="1">com.hazelcast.examples.PortableFactory</portable-factory>
        </portable-factories>
        <serializers>
            <global-serializer>com.hazelcast.examples.GlobalSerializerFactory</global-serializer>
            <serializer type-class="com.hazelcast.examples.DummyType"
                        class-name="com.hazelcast.examples.SerializerFactory"/>
        </serializers>
        <check-class-def-errors>true</check-class-def-errors>
        <java-serialization-filter defaults-disabled="true">
            <blacklist>
                <class>com.acme.app.BeanComparator</class>
            </blacklist>
            <whitelist>
                <class>java.lang.String</class>
                <class>example.Foo</class>
                <package>com.acme.app</package>
                <package>com.acme.app.subpkg</package>
                <prefix>com.hazelcast.</prefix>
                <prefix>java</prefix>
            </whitelist>
        </java-serialization-filter>
    </serialization>
</hazelcast>hazelcast:
  serialization:
    portable-version: 0
    use-native-byte-order: false
    byte-order: BIG_ENDIAN
    data-serializable-factories:
      - factory-id: 1
        class-name: com.hazelcast.examples.DataSerializableFactory
    portable-factories:
      - factory-id: 1
        class-name: com.hazelcast.examples.PortableFactory
    global-serializer:
      class-name: com.hazelcast.examples.GlobalSerializerFactory
    serializers:
      - type-class: com.hazelcast.examples.DummyType
        class-name: com.hazelcast.examples.SerializerFactory
    check-class-def-errors: true
    java-serialization-filter:
      defaults-disabled: true
      blacklist:
        class:
          - com.acme.app.BeanComparator
      whitelist:
        class:
          - java.lang.String
          - example.Foo
        package:
          - com.acme.app
          - com.acme.app.subpkg
        prefix:
          - com.hazelcast.
          - javaProgrammatic Configuration:
Config config = new Config();
SerializationConfig srzConfig = config.getSerializationConfig();
srzConfig.setPortableVersion( "2" ).setUseNativeByteOrder( true );
srzConfig.setAllowUnsafe( true ).setEnableCompression( true );
srzConfig.setCheckClassDefErrors( true );
GlobalSerializerConfig globSrzConfig = srzConfig.getGlobalSerializerConfig();
globSrzConfig.setClassName( "abc.Class" );
SerializerConfig serializerConfig = srzConfig.getSerializerConfig();
serializerConfig.setTypeClass( "Employee" )
                .setClassName( "com.EmployeeSerializer" );Serialization configuration has the following elements.
- 
portable-version: Defines versioning of the portable serialization. Portable version differentiates two of the same classes that have changes, such as adding/removing field or changing a type of a field.
- 
use-native-byte-order: Set totrueto use native byte order for the underlying platform. Its default value isfalse.
- 
byte-order: Defines the byte order that the serialization uses:BIG_ENDIANorLITTLE_ENDIAN. Its default value isBIG_ENDIAN.
- 
enable-compression: Enables compression if default Java serialization is used. Its default value isfalse.
- 
enable-shared-object: Enables shared object if default Java serialization is used. Its default value isfalse.
- 
allow-unsafe: Set totrueto allowunsafeto be used. Its default value isfalse.
- 
data-serializable-factory: Custom classes implementingcom.hazelcast.nio.serialization.DataSerializableFactoryto be registered. These can be used to speed up serialization/deserialization of objects.
- 
portable-factory: ThePortableFactoryclass to be registered.
- 
global-serializer: The global serializer class to be registered if no other serializer is applicable. This element has the optional boolean attributeoverride-java-serialization. If set totrue, the Java serialization step is assumed to be handled by the global serializer. Java Serializable and Externalizable is prior to global serializer by default (false).
- 
serializer: The class name of the serializer implementation.
- 
check-class-def-errors: When set totrue, the serialization system checks for class definitions error at start and throws a Serialization Exception with an error definition.
- 
java-serialization-filter: Provides deserialization protection based on whitelisting and blacklisting the class/package names.
- 
compact-serialization-config: (BETA) Provides ways to enable Compact serialization, register explicit or reflective Compact serializers for classes. See CompactSerializationConfig section for details.