gpt4 book ai didi

java - 使用 jclouds API 创建 aws-ec2 实例

转载 作者:搜寻专家 更新时间:2023-11-01 03:52:12 25 4
gpt4 key购买 nike

我正在尝试使用 jclouds 创建一个 aws-ec2 实例。执行代码时出现以下异常

"java.util.NoSuchElementException: key [aws-ec2] not in the list of providers or apis: {}".

如何解决这个异常?

最佳答案

您需要确保您的类路径中有 aws-ec2-X.X.X.jar。要获取 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>

关于java - 使用 jclouds API 创建 aws-ec2 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23077117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com