This topic describes how to install ApsaraVideo Media Processing (MPS) V2.0 for Java by using Maven.
Prerequisites
Java 8 or later is installed.
Procedure
The installation procedure consists of two steps: Add the Maven repository of Alibaba Cloud SDK for Java to the pom.xml file and add MPS dependencies.
Add the Maven repository.
<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>
Add dependencies.
The following sample code shows the dependencies on the core library version 4.6.0 of Alibaba Cloud SDK for Java and MPS SDK for Java 3.3.45.
<dependency> <groupId>com.aliyun</groupId> <artifactId>mts20140618</artifactId> <version>5.0.0</version> </dependency>
In addition to the preceding libraries, you can also add JSON library dependencies. Many parameters in MPS API operations are in the JSON format. Therefore, you can select available libraries from the JSON libraries for Java. In this example, JSON library 1.2.68.noneautotype is used. The following sample code provides an example of the content of the pom.xml file:
<?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> <!-- Optional. Add the Key Management Service (KMS) dependency. --> <dependency> <groupId>com.aliyun</groupId> <artifactId>kms20160120</artifactId> <version>1.2.2</version> </dependency> <!-- Optional. Add the Security Token Service (STS) dependency. --> <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>