这是Google Guice调用代码:
public static ContainerRunner forInjector(Injector injector) {
return (ContainerRunner)injector.getInstancefaultContainerRunner.class);
}
public static ContainerRunner forModules(Iterable<? extends Module> modules) {
return forInjector(Guice.createInjector(modules));
}
这就是例外:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.inject.internal.Initializer.requestInjection(Lcom/google/inject/internal/InjectorImpl;Ljava/lang/Object;Lcom/google/inject/Binding;Ljava/lang/Object;Ljava/util/Set;)Lcom/google/inject/internal/Initializable;
at com.google.inject.internal.BindingProcessor$1.visit(BindingProcessor.java:108)
at com.google.inject.internal.BindingProcessor$1.visit(BindingProcessor.java:70)
at com.google.inject.internal.ProviderInstanceBindingImpl.acceptTargetVisitor(ProviderInstanceBindingImpl.java:62)
at com.google.inject.internal.BindingProcessor.visit(BindingProcessor.java:70)
at com.google.inject.internal.BindingProcessor.visit(BindingProcessor.java:43)
at com.google.inject.internal.BindingImpl.acceptVisitor(BindingImpl.java:93)
at com.google.inject.internal.AbstractProcessor.process(AbstractProcessor.java:56)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:186)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.baml.gmt.xasf.container.ContainerRunners.forModules(ContainerRunners.java:39)
我的问题是该消息并未告诉我缺少哪种特定方法。调试这个有好方法吗?这可能是Maven传递依赖问题吗?
答案 0 :(得分:0)
它告诉你究竟缺少什么方法。它&#39; S:
com.google.inject.internal.Initializer
考虑到方法签名最后一次更改Five years ago,您几乎肯定会遇到某种构建问题,导致该方法不能以某种方式存在于类路径中。您还没有给我们足够的信息以便能够进一步调试。
答案 1 :(得分:0)
事实证明,当我在Unix环境中执行时,lib目录中的文件存在权限问题。一旦我更改了权限,就会超过此Guice错误。从我的粘贴体验来看,这个Guice错误几乎总是由于依赖性问题,无论如何。但是,Guice没有为您提供更具体,更具描述性的错误消息。