全部产品
云市场
云游戏

安装

更新时间:2019-10-30 15:35:32

本文介绍阿里云Java SDK推荐的Maven安装方式。具体包含2个步骤,首先需要在pom.xml配置文件中添加阿里云Java SDK的Maven仓库,然后再添加智能视觉的依赖。

  1. 添加maven仓库。

    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. 添加依赖阿里云Java SDK核心库以及智能视觉Java SDK的详细版本:

以3.5.0版本SDK的核心库和1.1.0版本的智能视觉SDK为例:

  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-ivision</artifactId>
  9. <version>1.1.0</version>
  10. </dependency>

另外有一个可选的json库依赖。在智能视觉的API中,很多参数都是json定义,java的json库有很多,可以选择熟悉的库,以1.2.51版本的 fastjson 为例:

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

pom.xml完整示例:

  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>com.aliyun.ivision</groupId>
  6. <artifactId>demo</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-ivision</artifactId>
  30. <version>1.0.0</version>
  31. </dependency>
  32. <dependency>
  33. <groupId>com.alibaba</groupId>
  34. <artifactId>fastjson</artifactId>
  35. <version>1.2.51</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>