Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Guice:“我不知道你是谁。”;找不到合适的构造函数“;当FactoryBuilder中提供合适的构造函数时_Java_Dependency Injection_Guice_Factory - Fatal编程技术网

Java Guice:“我不知道你是谁。”;找不到合适的构造函数“;当FactoryBuilder中提供合适的构造函数时

Java Guice:“我不知道你是谁。”;找不到合适的构造函数“;当FactoryBuilder中提供合适的构造函数时,java,dependency-injection,guice,factory,Java,Dependency Injection,Guice,Factory,我正在使用Guice进行依赖项注入,但出现以下错误: 1) Could not find a suitable constructor in java.lang.Void. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private. at java.lang.Void.class(Void.j

我正在使用Guice进行依赖项注入,但出现以下错误:

1) Could not find a suitable constructor in java.lang.Void. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
  at java.lang.Void.class(Void.java:44)
  while locating java.lang.Void
  at com.myfeed.algorithm.clusterer.tree.wrapper.ItemSourceTreeWrapperFactory.create(ItemSourceTreeWrapperFactory.java:1)
特别奇怪的是,它提到了java.lang.Void

这是模块代码:(我将类绑定到自身,而不是类的接口)

安装(新的FactoryModuleBuilder()。实现(
新建TypeLiteral(){},ItemSourceTreeWrapper.class
).build(新的TypeLiteral(){});
下面是ItemSourceTreeWrapper构造函数

@Inject
public ItemSourceTreeWrapper(@Assisted Tree<Item<Source>> treeToWrap, @Assisted ItemGroup itemGroup, Itemizer<Source> itemizer, SourceItemConverterFactory sourceItemConverterFactory) {
    this.treeToWrap = treeToWrap;
    this.itemizer = itemizer;
    sourceItemConverter = sourceItemConverterFactory.create(itemGroup, itemizer);
}
public interface ItemSourceTreeWrapperFactory<Source> {
    public void create(Tree<Item<Source>> treeToWrap, ItemGroup<Source> itemGroup);
}
@Inject
public ItemSourceTreeWrapper(@Assisted Tree treeToWrap、@Assisted ItemGroup ItemGroup、Itemizer Itemizer、SourceItemConverterFactory SourceItemConverterFactory){
this.treeToWrap=treeToWrap;
this.itemizer=itemizer;
sourceItemConverter=sourceItemConverterFactory.create(itemGroup,itemizer);
}
下面是工厂界面:

@Inject
public ItemSourceTreeWrapper(@Assisted Tree<Item<Source>> treeToWrap, @Assisted ItemGroup itemGroup, Itemizer<Source> itemizer, SourceItemConverterFactory sourceItemConverterFactory) {
    this.treeToWrap = treeToWrap;
    this.itemizer = itemizer;
    sourceItemConverter = sourceItemConverterFactory.create(itemGroup, itemizer);
}
public interface ItemSourceTreeWrapperFactory<Source> {
    public void create(Tree<Item<Source>> treeToWrap, ItemGroup<Source> itemGroup);
}
公共接口项SourceTreeWrapperFactory{
公共void创建(树状树状结构,ItemGroup ItemGroup);
}

implement()
的调用看起来可疑-由于
ItemSourceTreeWrapper
是泛型的,第二个参数可能使用
TypeLiteral
。此外,由于您是用自身实现一个类,因此应该能够完全省略
implement()
调用

但您实际的问题是,在
ItemSourceTreeWrapperFactory
中,
public void create(…)
可能应该是
public ItemSourceTreeWrapper create(…)