1 Star 0 Fork 1

wl4g-collect / aliyun-openapi-java-sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

English | 简体中文

Alibaba Cloud SDK for Java

Latest Stable Version

欢迎使用 Alibaba Cloud SDK for Java 。Alibaba Cloud SDK for Java 让您不用复杂编程即可访问云服务器、云监控等多个阿里云服务。 这里向您介绍如何获取 Alibaba Cloud SDK for Java 并开始调用。 如果您在使用 Alibaba Cloud SDK for Java 的过程中遇到任何问题,欢迎在当前 GitHub 提交 Issues

环境要求

  1. 要使用 Alibaba Cloud SDK for Java ,您需要一个云账号以及一对Access Key IDAccess Key Secret。 请在阿里云控制台中的AccessKey管理页面上创建和查看您的Access Key,或者联系您的系统管理员。
  2. 要使用 Alibaba Cloud SDK for Java 访问某个产品的API,您需要事先在阿里云控制台中开通这个产品。
  3. Alibaba Cloud SDK for Java 需要1.6以上的JDK。

安装依赖

无论您要使用哪个产品的开发工具包,都必须安装aliyun-java-sdk-core。比如,对云服务器SDK的调用,您需要安装aliyun-java-sdk-corealiyun-java-sdk-ecs

通过Maven来管理项目依赖(推荐)

如果您使用Apache Maven来管理Java项目,只需在项目的pom.xml文件加入相应的依赖项即可。您可以在阿里云开发者资源中下载各云产品的Maven依赖。 以使用Ecs SDK为例,您只需在pom.xml中声明以下两个依赖:

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>[4.4.9,5.0.0)</version>
</dependency>
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-ecs</artifactId>
    <version>[4.16.0,5.0.0)</version>
</dependency>

如果 maven 没有从中央存储库下载 jar 包,则需要将这些依赖项添加到pom.xml文件中,否则将报告 NoClassDefFoundError 异常

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.5</version>
</dependency>
<dependency>
    <groupId>io.opentracing</groupId>
    <artifactId>opentracing-api</artifactId>
    <version>0.33.0</version>
</dependency>
<dependency>
    <groupId>io.opentracing</groupId>
    <artifactId>opentracing-util</artifactId>
    <version>0.33.0</version>
</dependency>

快速使用

以下这个代码示例向您展示了调用 Alibaba Cloud SDK for Java 的3个主要步骤:

  1. 创建DefaultAcsClient实例并初始化。
  2. 创建API请求并设置参数。
  3. 发起请求并处理应答或异常。
package com.testprogram;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.ecs.model.v20140526.*;
public class Main {
    public static void main(String[] args) {
         // 创建DefaultAcsClient实例并初始化
        DefaultProfile profile = DefaultProfile.getProfile(
            "<your-region-id>",          // 地域ID
            "<your-access-key-id>",      // RAM账号的AccessKey ID
            "<your-access-key-secret>"); // RAM账号Access Key Secret
        IAcsClient client = new DefaultAcsClient(profile);
         // 创建API请求并设置参数
        DescribeInstancesRequest request = new DescribeInstancesRequest();
        request.setPageSize(10);
        // 发起请求并处理应答或异常
        DescribeInstancesResponse response;
        try {
            response = client.getAcsResponse(request);
            for (DescribeInstancesResponse.Instance instance:response.getInstances()) {
                System.out.println(instance.getPublicIpAddress());
            }
        } catch (ServerException e) {
            e.printStackTrace();
         } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}

文档

问题

提交 Issue,不符合指南的问题可能会立即关闭。

发行说明

每个版本的详细更改记录在发行说明中。

贡献

提交 Pull Request 之前请阅读贡献指南

相关

许可证

Apache-2.0

Copyright (c) 2009-present, Alibaba Cloud All rights reserved.

Copyright (c) 2009-present, Alibaba Cloud All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Alibaba Cloud SDK for Java 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/wl4g-collect/aliyun-openapi-java-sdk.git
git@gitee.com:wl4g-collect/aliyun-openapi-java-sdk.git
wl4g-collect
aliyun-openapi-java-sdk
aliyun-openapi-java-sdk
master

搜索帮助