我的代码相当简单,并且由 Eclipse 生成。
public class BuchAnalysisPresenter extends
Presenter<BuchAnalysisPresenter.MyView, BuchAnalysisPresenter.MyProxy>
implements BuchAnalysisUiHandlers {
interface MyView extends View, HasUiHandlers<BuchAnalysisUiHandlers> {
SimplePanel getMain();
}
@ContentSlot
public static final Type<RevealContentHandler<?>> SLOT_BUCHNR = new Type<RevealContentHandler<?>>();
@NameToken(NameTokens.buchnummer)
@ProxyStandard
interface MyProxy extends ProxyPlace<BuchAnalysisPresenter> {
}
@Inject
VerlagServiceAsync verlagServiceAsync;
@Inject
BuchAnalysisPresenter(EventBus eventBus, MyView view, MyProxy proxy) {
super(eventBus, view, proxy, HomePagePresenter.SLOT_SetGraphContent);
getView().setUiHandlers(this);
}
}
但是我收到一个编译错误:
无法创建或继承绑定(bind):未找到 de.it2media.dps.statistics.client.application.buchnranalysis.BuchAnalysisPresenter$MyView 的 @Inject 或默认构造函数
正如您在代码中看到的,实际上有一个构造函数 BuchAnalysisPresenter
以及它的 @Inject
注释。
我对 Spring
很陌生,不知道为什么会发生这种情况。
最佳答案
我找到了解决方案。我只需调用 GinBinder
的 install()
方法并像这样初始化我的模块 BuchAnalysisModule
。无需进行其他更改。
public class ApplicationModule extends AbstractPresenterModule {
@Override
protected void configure() {
install(new BuchAnalysisModule());
bindPresenter(ApplicationPresenter.class,
ApplicationPresenter.MyView.class, ApplicationView.class,
ApplicationPresenter.MyProxy.class);
}
}
关于java - Spring 中没有找到 @Inject 或默认构造函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33018123/