【发布时间】:2014-03-22 13:51:48
【问题描述】:
我有一个移动文件:
<extend-configuration-property name="gin.ginjector.extensions" value="test.client.gin.ClientInjectorAdditional"/>
我的 ClientInjectorAdditional 是:
public interface ClientInjectorAdditional extends Ginjector {
NotificationFetcher getNotificationFetcher();
}
现在我想在我的入口点类中注入 NotificationFetcher。我试过了
public class Test implements EntryPoint {
private static final ApplicationController controller = GWT.create(ApplicationController.class);
@Inject
private NotificationFetcher notificationFetcher;
@Override
public void onModuleLoad() {
controller.init(;
...
}
}
问题是notificationFetcher 没有被注入。
如何将 GWTP 与 ginjector 扩展一起使用?
编辑:
当我使用时
private final ClientInjectorAdditional injector = GWT.create(ClientInjectorAdditional.class);
我收到以下警告:
No gin modules are annotated on Ginjector interface test.client.gin.ClientInjectorAdditional, did you forget the @GinModules annotation?
编辑:
我试过了:
@GinModules({ ClientModule.class }) 公共接口 ClientInjectorAdditional 扩展 Ginjector { ... }
但这会产生以下错误:
[DEBUG] [test] - Rebinding test.client.gin.ClientInjectorAdditional
[DEBUG] [test] - Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
[ERROR] [test] - Error injecting com.gwtplatform.dispatch.rest.client.ActionMetadataProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.ActionMetadataProvider
Path to required node:
com.gwtplatform.dispatch.rest.client.RestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:99)]
-> com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:99)]
-> com.gwtplatform.dispatch.rest.client.ActionMetadataProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory]
[ERROR] [test] - Error injecting com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider
Path to required node:
com.gwtplatform.dispatch.rest.client.serialization.Serialization [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:103)]
-> com.gwtplatform.dispatch.rest.client.serialization.JsonSerialization [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:103)]
-> com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.serialization.JsonSerialization]
[ERROR] [test] - Deferred binding failed for 'test.client.gin.ClientInjectorAdditional'; expect subsequent failures
[ERROR] [test] - Failed to create an instance of 'test.client.test' via deferred binding
[ERROR] [test] - Unable to load module entry point class test.client.test (see associated exception for details)
[ERROR] [test] - Failed to load module 'test' from user agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' at http-server.fritz.box:61196
【问题讨论】:
-
尝试分析异常。读它在说什么?并按照我的帖子中提到的说明进行操作。我没有使用过@Inject。
No default constructor found for com.gwtplatform.dispatch.rest.client.ActionMetadataProvider和No default constructor found for com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider -
从 gwt.xml 中删除
<extend-configuration-property name="gin.ginjector.extensions"...。使用GWT.create() -
在这种情况下我必须使用
-
首先尝试按照我的帖子中提到的步骤进行操作。让我知道它是否不起作用。除非我有完整的代码,否则我不能说。使用
GWT.create()代替@Inject。 -
您是否正在使用 gwtp 并为您自动生成 gingector?
标签: java javascript gwt gwtp gwt-platform