老的 msgpack-java(例如 0.6.7)并不支持 MessagePack str8 数据类型。

当你的希望的你的应用程序需要支持老的版本的话,你需要禁用这个数据类型,例如使用下面的语句:

MessagePack.PackerConfig config = new MessagePack.PackerConfig().withStr8FormatSupport(false); Mapper mapperWithConfig = new  Mapper(new MessagePackFactory(config));// This string is serialized as bin8 typebyte[] resultWithoutStr8Format = mapperWithConfig.writeValueAsBytes(str8LengthString);

https://www.cwiki.us/display/Serialization/MessagePack+Jackson+Dataformat

收藏 打印