edit-icon download-icon

Installation

Last Updated: Mar 02, 2018

This documentation introduces Maven installation method recommended by Alibaba Cloud Java SDK. Specifically, it includes two steps. First, add the Maven repository of Alibaba Cloud Java SDK to the pom.xml configuration file. Then, add MPS dependency.

  1. Add a Maven repository.

    1. <repositories>
    2. <repository>
    3. <id>sonatype-nexus-staging</id>
    4. <name>Sonatype Nexus Staging</name>
    5. <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    6. <releases>
    7. <enabled>true</enabled>
    8. </releases>
    9. <snapshots>
    10. <enabled>true</enabled>
    11. </snapshots>
    12. </repository>
    13. </repositories>
  2. Add dependency.

    Alibaba Java SDK Core and MPS Java SDK detailed version:

    Take the core of V3.5.0 SDK Core and V2.5.2 MPS SDK as an example:

    1. <dependency>
    2. <groupId>com.aliyun</groupId>
    3. <artifactId>aliyun-java-sdk-core</artifactId>
    4. <version>3.5.0</version>
    5. </dependency>
    6. <dependency>
    7. <groupId>com.aliyun</groupId>
    8. <artifactId>aliyun-java-sdk-mts</artifactId>
    9. <version>2.5.2</version>
    10. </dependency>

    In addition, a json repository dependency optional. In MPS API, many parameters are defined through json. And many json repositories for java are available, you can select the repository that you are familiar with. Take V1.2.46 fastjson as an example:

    1. <dependency>
    2. <groupId>com.alibaba</groupId>
    3. <artifactId>fastjson</artifactId>
    4. <version>1.2.46</version>
    5. </dependency>

pom.xml example:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>mps-demo-project</groupId>
  6. <artifactId>mps-demo-project</artifactId>
  7. <version>0.0.1-SNAPSHOT</version>
  8. <repositories>
  9. <repository>
  10. <id>sonatype-nexus-staging</id>
  11. <name>Sonatype Nexus Staging</name>
  12. <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
  13. <releases>
  14. <enabled>true</enabled>
  15. </releases>
  16. <snapshots>
  17. <enabled>true</enabled>
  18. </snapshots>
  19. </repository>
  20. </repositories>
  21. <dependencies>
  22. <dependency>
  23. <groupId>com.aliyun</groupId>
  24. <artifactId>aliyun-java-sdk-core</artifactId>
  25. <version>3.5.0</version>
  26. </dependency>
  27. <dependency>
  28. <groupId>com.aliyun</groupId>
  29. <artifactId>aliyun-java-sdk-mts</artifactId>
  30. <version>2.5.2</version>
  31. </dependency>
  32. <dependency>
  33. <groupId>com.alibaba</groupId>
  34. <artifactId>fastjson</artifactId>
  35. <version>1.2.46</version>
  36. </dependency>
  37. </dependencies>
  38. <build>
  39. <finalName>${artifactId}-${version}</finalName>
  40. <plugins>
  41. <plugin>
  42. <groupId>org.apache.maven.plugins</groupId>
  43. <artifactId>maven-compiler-plugin</artifactId>
  44. <version>2.3.2</version>
  45. <configuration>
  46. <source>1.6</source>
  47. <target>1.6</target>
  48. </configuration>
  49. </plugin>
  50. </plugins>
  51. </build>
  52. </project>
Thank you! We've received your feedback.