0

我正在尝试使用 Jcloud openstack neutron API,并且在尝试运行时遇到了此异常,我尝试如下构建 neutronApi。以此为例https://gist.github.com/everett-toews/8701756

    Iterable<Module> modules = ImmutableSet.<Module>of();

    String provider = "openstack-neutron";
    String identity = "admin:admin"; // tenantName:userName
    String credential = "devstack";

    Properties prop = new Properties();
    prop.setProperty("jclouds.relax-hostname", "true");
    prop.setProperty("jclouds.trust-all-certs", "true");

    neutronApi = ContextBuilder.newBuilder(provider)
            .endpoint("https://<devstack IP>:5000/v2.0")
            .credentials(identity, credential)
            .modules(modules).overrides(prop)
            .buildApi(NeutronApi.class);

我得到以下异常

 [java] Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:
 [java] 1) No implementation for org.jclouds.openstack.neutron.v2_0.NeutronApi was bound.
 [java]   while locating org.jclouds.openstack.neutron.v2_0.NeutronApi
 [java] 1 error
 [java]     at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004)
 [java]     at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1009)
 [java]     at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:655)
 [java]     at org.jclouds.ContextBuilder.buildApi(ContextBuilder.java:647)
 [java]     at openstack.NovaOpenstack.<init>(Unknown Source)
 [java]     at bootstrap.OpenstackBootstrap.main(Unknown Source)

Jcloud jar 版本 - 1.8,番石榴 - 3.0,guice - 1.7

请让我知道我做错了什么或如何解决这个问题。

提前致谢。

4

1 回答 1

0
import org.jclouds.openstack.neutron.v2.NeutronApi;

import org.jclouds.openstack.neutron.v2.domain.Network;

import org.jclouds.openstack.neutron.v2.domain.NetworkStatus;

import org.jclouds.openstack.neutron.v2.domain.NetworkType;

import org.jclouds.openstack.neutron.v2.domain.Networks;

import org.jclouds.openstack.neutron.v2.features.NetworkApi;

import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions;

使用上述进口

并根据导入更改代码中的方法

于 2014-12-06T16:51:40.510 回答