我正在尝试使用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 ver - 1.8,guava - 3.0,guice - 1.7
请让我知道我做错了什么或如何解决这个问题。
提前致谢。
答案 0 :(得分: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;
使用上述导入
并根据导入
更改代码中的方法