在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:aliyun/aliyun-openapi-java-sdk开源软件地址:https://github.com/aliyun/aliyun-openapi-java-sdk开源编程语言:Java 100.0%开源软件介绍:English | 简体中文 Alibaba Cloud SDK for JavaThe Alibaba Cloud SDK for Java allows you to access Alibaba Cloud services such as Elastic Compute Service (ECS), Server Load Balancer (SLB), and CloudMonitor. You can access Alibaba Cloud services without the need to handle API related tasks, such as signing and constructing your requests. This document introduces how to obtain and call Alibaba Cloud SDK for Java. If you have any problem while using Alibaba Cloud SDK for Java, please submit an issue. Requirements
InstallationIf you use Apache Maven to manage Java projects, you only need to add corresponding dependencies to the pom.xml files of the projects. You can download the Maven dependencies of different cloud products in Alibaba Cloud developer resources. You must install To use the Ecs SDK as an example, you only need to declare the following two dependencies in the <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> If maven is not downloading jar packages from a central repository, you need to add these dependencies in the pom.xml file, or a NoClassDefFoundError exception will be reported <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> TroubleshootTroubleshoot Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through Quick ExamplesThe following code example shows the three main steps to use Alibaba Cloud SDK for Java :
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) {
// Create and initialize a DefaultAcsClient instance
DefaultProfile profile = DefaultProfile.getProfile(
"<your-region-id>", // The region ID
"<your-access-key-id>", // The AccessKey ID of the RAM account
"<your-access-key-secret>"); // The AccessKey Secret of the RAM account
IAcsClient client = new DefaultAcsClient(profile);
// Create an API request and set parameters
DescribeInstancesRequest request = new DescribeInstancesRequest();
request.setPageSize(10);
// Initiate the request and handle the response or exceptions
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();
}
}
} Documentation
IssuesOpening an Issue, Issues not conforming to the guidelines may be closed immediately. ChangelogDetailed changes for each release are documented in the release notes. ContributionPlease make sure to read the Contributing Guide before making a pull request. ReferencesLicenseCopyright (c) 2009-present, Alibaba Cloud All rights reserved. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论