我在这里关注 Azure 关于 Java API 的基本教程:https://www.windowsazure.com/en-us/develop/java/how-to-guides/table-service/#CreateTable
但遇到以下错误:
cannot find symbol
symbol : method createTableIfNotExists(java.lang.String)
location: class com.microsoft.windowsazure.services.table.client.CloudTableClient
完整的小程序(从Azure教程复制):
import com.microsoft.windowsazure.services.core.storage.*;
import com.microsoft.windowsazure.services.table.client.*;
import com.microsoft.windowsazure.services.table.client.TableQuery.*;
public class AzureTableWrite {
public static void main(String[] args) {
// Define the connection-string with your values
final String storageConnectionString =
"DefaultEndpointsProtocol=http;" +
"AccountName=skivvy;" +
"AccountKey=foobar";
// Retrieve storage account from connection-string
CloudStorageAccount storageAccount =
CloudStorageAccount.parse(storageConnectionString);
// Create the table client.
CloudTableClient tableClient = storageAccount.createCloudTableClient();
// Create the table if it doesn't exist.
String tableName = "people";
tableClient.createTableIfNotExists(tableName);
}
}
有人遇到过同样的问题吗?如有任何帮助,我们将不胜感激!
最佳答案
正如我在 MSDN 论坛 ( http://social.msdn.microsoft.com/Forums/en-US/windowsazuredata/thread/78c12f97-4209-41a1-86d6-267f5e9f51f6 ) 上的回复中提到的,您使用的示例似乎存在问题。
请改用这个:
CloudTableClient tableClient = storageAccount.createCloudTableClient();
CloudTable table = tableClient.getTableReference("people");
table.createIfNotExists();
希望这有帮助。
关于Azure表存储: can't create a table with a CloudTableClient instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12668170/