安裝
更新時(shí)間:
本文介紹阿里云Java SDK V2.0推薦的Maven安裝方式。
環(huán)境準(zhǔn)備
推薦使用Java 8及以上版本。
安裝步驟
安裝包含2個(gè)步驟,首先需要在pom.xml配置文件中添加阿里云Java SDK的Maven倉庫,然后再添加媒體處理的依賴。
添加Maven倉庫。
<repositories> <repository> <id>sonatype-nexus-staging</id> <name>Sonatype Nexus Staging</name> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>
添加依賴。
阿里云Java SDK核心庫以及媒體處理Java SDK的詳細(xì)版本如下,下文示例代碼以4.6.0版本Java SDK的核心庫和3.3.45版本的媒體處理Java SDK為例:
<dependency> <groupId>com.aliyun</groupId> <artifactId>mts20140618</artifactId> <version>5.0.0</version> </dependency>
除上述庫外,還有一個(gè)可選的JSON庫依賴。在媒體處理的API中,很多參數(shù)都是JSON,您可以從Java的JSON庫中選擇熟悉的庫。下文示例代碼以1.2.68.noneautotype為例,pom.xml完整示例如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.alibaba</groupId> <artifactId>mps-java-sdk-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>mps-java-sdk-demo</name> <description>Demo project for Spring Boot</description> <packaging>pom</packaging> <repositories> <repository> <id>sonatype-nexus-staging</id> <name>Sonatype Nexus Staging</name> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <properties> <java.version>1.8</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <spring-boot.version>2.2.6.RELEASE</spring-boot.version> </properties> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.8.1</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.68.noneautotype</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.6</version> </dependency> <!-- kms密鑰服務(wù)相關(guān)依賴,非必須 --> <dependency> <groupId>com.aliyun</groupId> <artifactId>kms20160120</artifactId> <version>1.2.2</version> </dependency> <!-- sts相關(guān)依賴,非必須 --> <dependency> <groupId>com.aliyun</groupId> <artifactId>sts20150401</artifactId> <version>1.1.4</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>alibabacloud-mts20140618</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>tea-openapi</artifactId> <version>0.3.4</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>tea-console</artifactId> <version>0.0.1</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>tea-util</artifactId> <version>0.2.22</version> </dependency> </dependencies> </project>
文檔內(nèi)容是否對(duì)您有幫助?