我正在尝试学习如何使用 Protostuff。我有一个使用 protostuff 1.0.7 的示例。在此示例中使用了 RuntimeSchema 类。
当我尝试使用当前版本的 protostuff (1.3.8) 重现代码时,我失败了,因为 RuntimeSchema 类似乎不存在。我在网上搜索了当前的教程,但我能找到的只是: https://github.com/protostuff/protostuff/wiki/Examples 老实说,我不明白。
有人可以帮助我了解 protostuff 在当前版本中应该如何使用吗?
最佳答案
我检查了自己的代码来看看你,这就是我正在做的事情:
LinkedBuffer buffer = LinkedBuffer.allocate(2048);
Schema<Order> orderSchema = RuntimeSchema.getSchema(Order.class);
ProtostuffIOUtil.toByteArray(order2, orderSchema, buffer);
buffer.clear();
实际上与示例相同。我唯一可以建议做的是你的 POM 包含所有三个依赖项:
- Protostuff Runtime(您可能缺少的那个)
- Protostuff API
- 原型(prototype)核心
将来,解决此类问题的最佳方法始终是您拥有所有必要的依赖项。
关于java - Protostuff 1.3.8 中的运行时架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34929251/