Cloud Datastore Key fromUrlSafe() 未编译
Cloud Datastore Key fromUrlSafe() not compiling
我正在尝试创建一个基于已知 URL 安全密钥的密钥对象。从 API 看来,我应该使用
Key k = fromUrlSafe(URL_safe_key);
使用导入语句
import com.google.cloud.datastore.*;
但是,在编译时(我在 App Engine shell 中使用 Maven),导入语句正确加载但出现错误提示找不到方法:
cannot find symbol
symbol: method fromUrlSafe(java.lang.String)
代码有什么问题,或者我应该使用其他方法吗?
在 Java 中,您永远无法通过导入模块来导入不属于 class 的 "local methods"。 fromUrlSafe 必须是您从 com.google.cloud.datastore.
导入的 class 的实例或静态方法
在本例中,fromUrlSafe is a static method from the Key Class,因此您的代码应改为:
Key k = Key.fromUrlSafe(URL_safe_key);
我正在尝试创建一个基于已知 URL 安全密钥的密钥对象。从 API 看来,我应该使用
Key k = fromUrlSafe(URL_safe_key);
使用导入语句
import com.google.cloud.datastore.*;
但是,在编译时(我在 App Engine shell 中使用 Maven),导入语句正确加载但出现错误提示找不到方法:
cannot find symbol
symbol: method fromUrlSafe(java.lang.String)
代码有什么问题,或者我应该使用其他方法吗?
在 Java 中,您永远无法通过导入模块来导入不属于 class 的 "local methods"。 fromUrlSafe 必须是您从 com.google.cloud.datastore.
导入的 class 的实例或静态方法在本例中,fromUrlSafe is a static method from the Key Class,因此您的代码应改为:
Key k = Key.fromUrlSafe(URL_safe_key);