4

我正在尝试使用jclouds. 在执行代码时,我收到以下异常

“java.util.NoSuchElementException:键 [aws-ec2] 不在提供程序或 API 列表中:{}”。

如何解决此异常?

4

1 回答 1

0

您需要确保您的类路径中有 aws-ec2-XXXjar。要获取 jar 文件,您可以使用 Maven pom.xml 之类的并执行mvn dependency:copy-dependencies -DoutputDirectory="./lib"

<?xml version="1.0"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <properties>
    <jclouds.version>1.7.1</jclouds.version>
  </properties>
  <name>Cloud Portability with Multi-Cloud Toolkits Workshop</name>
  <description>https://github.com/rackerlabs/multi-cloud-workshop/</description>
  <groupId>multi.cloud.workshop</groupId>
  <artifactId>multi-cloud-workshop</artifactId>
  <version>1.0</version>
  <dependencies>
    <!-- jclouds Dependencies -->
    <dependency>
      <groupId>org.apache.jclouds.driver</groupId>
      <artifactId>jclouds-slf4j</artifactId>
      <version>${jclouds.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.jclouds.driver</groupId>
      <artifactId>jclouds-sshj</artifactId>
      <version>${jclouds.version}</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.0.13</version>
    </dependency>
    <!-- Cloud Provider Dependencies -->
    <dependency>
      <groupId>org.apache.jclouds.provider</groupId>
      <artifactId>aws-ec2</artifactId>
      <version>${jclouds.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.jclouds.provider</groupId>
      <artifactId>hpcloud-compute</artifactId>
      <version>${jclouds.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.jclouds.provider</groupId>
      <artifactId>rackspace-cloudservers-us</artifactId>
      <version>${jclouds.version}</version>
    </dependency>
  </dependencies>
</project>
于 2014-04-15T19:30:41.923 回答