不支持参数化类型
Parameterized type not supported
这是我通过 Objectify 的 属性 定义:
@Unindex
@Load
private List<Ref<Achievement>> oTrophyCase;
public List<Ref<Achievement>> getTrophyCase() {
return oTrophyCase;
}
public void setTrophyCase(List<Ref<Achievement>> trophyCase) {
this.oTrophyCase = trophyCase;
}
虽然我见过其他设计相同但不相似的示例,但我在编译时遇到此错误:
错误:任务执行失败
':后端:appengineEndpointsGetClientLibs'。出现错误 运行
端点命令 get-client-lib:参数化类型
com.googlecode.objectify.Ref
不支持。
我正在使用 Objectify 5.1.5。
我正在寻找相同的答案并找到:
- gaeobjectify-parameterized-type-com-googlecode-objectify-ref-not-supported 表示
Google Cloud Endpoints is unable to serialise the Ref object because it is an arbitrary object defined by objectify, therefore not supported as the error indicates.
- objectify-with-cloud-endpoints 表示
There are two ways you can now approach the issue with the property.
- 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.
- 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.
但更有趣的是
This is an issue with Cloud Endpoints, not Objectify. CE appears to need some sort of custom serializer for unknown classes, like GWT. If you can figure out what is necessary, we might consider including it in the Objectify source.
所以我发现你可以按照上面的建议解决它,通过用 @ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
或 @ApiTransformer(value=class)
注释字段,其中 class 是一个自定义转换器,解释了编译器如何序列化对象。
这是我通过 Objectify 的 属性 定义:
@Unindex
@Load
private List<Ref<Achievement>> oTrophyCase;
public List<Ref<Achievement>> getTrophyCase() {
return oTrophyCase;
}
public void setTrophyCase(List<Ref<Achievement>> trophyCase) {
this.oTrophyCase = trophyCase;
}
虽然我见过其他设计相同但不相似的示例,但我在编译时遇到此错误:
错误:任务执行失败 ':后端:appengineEndpointsGetClientLibs'。出现错误 运行 端点命令 get-client-lib:参数化类型 com.googlecode.objectify.Ref 不支持。
我正在使用 Objectify 5.1.5。
我正在寻找相同的答案并找到:
- gaeobjectify-parameterized-type-com-googlecode-objectify-ref-not-supported 表示
Google Cloud Endpoints is unable to serialise the Ref object because it is an arbitrary object defined by objectify, therefore not supported as the error indicates.
- objectify-with-cloud-endpoints 表示
There are two ways you can now approach the issue with the property.
- 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.- 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.
但更有趣的是
This is an issue with Cloud Endpoints, not Objectify. CE appears to need some sort of custom serializer for unknown classes, like GWT. If you can figure out what is necessary, we might consider including it in the Objectify source.
所以我发现你可以按照上面的建议解决它,通过用 @ApiResourceProperty(ignored = AnnotationBoolean.TRUE)
或 @ApiTransformer(value=class)
注释字段,其中 class 是一个自定义转换器,解释了编译器如何序列化对象。