请注意:尽管此问题涉及JClouds-Chef库和Groovy,但我认为这是Java API的核心问题。

在JClouds-Chef 1.7.3上,这里:

List<String> runlist = new RunListBuilder().addRole("typicalapp").build();

ArrayList<String> runList2 = new ArrayList<String>();
for(String item : runlist) {
    runList2.add(item);
}

System.out.println("runList2 is of type: " + runList2.getClass().getName());

BootstrapConfig bootstrapConfig = BootstrapConfig.builder().runlist(runList2).build();


产生以下输出/异常:

runList2 is of type: java.util.ArrayList
Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: org.jclouds.chef.domain.BootstrapConfig$Builder.runlist() is applicable for argument types: (java.util.ArrayList) values: [[role[typicalapp]]]
Possible solutions: runList(java.lang.Iterable), build(), split(groovy.lang.Closure)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
    at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at net.myuser.chef.test.ChefPlugin.provision(ChefPlugin.groovy:71)
    at net.myuser.chef.test.ChefPlugin$provision.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at net.myuser.chef.test.ChefPlugin.main(ChefPlugin.groovy:27)


我很确定此BootstrapConfig#Builder is here版本的代码。据我所知,ArrayList扩展了Iterable,所以我看不到这里发生了什么。

最佳答案

您正在使用runlist而不是runList

关于java - JClouds-Chef BootstrapConfig构建器MissingMethodException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24866057/

10-09 05:22