通过云端点进行物化 [英] Objectify with Cloud Endpoints

查看:146
本文介绍了通过云端点进行物化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用appengine云端点并进行物化。我之前已经部署了这些端点,现在我正在更新它们,并且它不适用于Objectify。我已经搬到新机器上并运行最新的appengine 1.8.6。已经尝试在classpath中添加objectify并且没有工作。我知道这可以工作,我错过了什么?



运行endpoints.sh时:

 错误:参数化类型
com.googlecode.objectify.Key< MyClass>不支持。

更新:
我回到旧电脑并在同一端点上运行endpoints.sh它运行良好。旧机器有1.8.3。我正在使用objectify 3.1。

更新2:
将我的旧机器更新至1.8.6,并获得与其他机器相同的错误。留下两种可能性:
1)端点不再支持客观化3.1

2)终端在最新版本中有一个错误

最有可能的#1 ...我一直有意更新到4.0反正...

解决方案

<由于Objectify的普及,在以前的版本中添加了一种解决方法来支持 Key 类型,直到提供更通用的解决方案。由于新解决方案可用,解决方法已被删除。现在有两种方法可以解决该问题。


  1. 添加 @ApiResourceProperty 注释,这会导致在序列化过程中从对象中省略键。如果您想要简单的解决方案并且无需访问客户端中的密钥,请使用此方法。 添加 @ApiTransformer 注释,它提供了一种兼容机制来序列化/反序列化字段。如果需要访问客户中的密钥(或其代表),请使用此方法。因为这需要编写一个转换器类,所以它比第一个选项更有用。


I am using appengine cloud endpoints and objectify. I have previously deployed these endpoints before and now I am updating them and it is not working with Objectify. I have moved to a new machine and running latest appengine 1.8.6. Have tried putting objectify in the classpath and that did not work. I know this can work, what am I missing??

When running endpoints.sh:

Error: Parameterized type
   com.googlecode.objectify.Key<MyClass> not supported.

UPDATE: I went back to my old computer and ran endpoints.sh on same endpoint and it worked fine. Old machine has 1.8.3. I am using objectify 3.1.

UPDATE 2: Updated my old machine to 1.8.6 and get same error as other machine. Leaves 2 possibilities: 1) Endpoints no longer support objectify 3.1 or 2) Endpoints have a bug in most recent version

Most likely #1...I've been meaning to update to 4.0 anyways...

解决方案

Because of the popularity of Objectify, a workaround was added in prior releases to support the Key type, until a more general solution was available. Because the new solution is available, the workaround has been removed. There are two ways you can now approach the issue with the property.

  1. Add an @ApiResourceProperty annotation that causes the key to be omitted from your object during serialization. Use this approach if you want a simple solution and don't need access to the key in your clients.
  2. Add an @ApiTransformer annotation that provides a compatible mechanism to serialize/deserialize the field. Use this approach if need access to the key (or a representation of it) in your clients. As this requires writing a transformer class, it is more work than the first option.

这篇关于通过云端点进行物化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆