I have a problem using Gin. Here is a simple example.
@GinModules(AppModule.class)
public interface AppInjector extends Ginjector
{
MainForm getMainPanel();
TemplateForm getHeaderForm();
}
then here is Module
import com.google.inject.Singleton;
public class AppModule extends AbstractGinModule
{
@Override
protected void configure()
{
bind(MainForm.class).in(Singleton.class);
}
}
and the Entry point
public class MySampleApplication implements EntryPoint
private final AppInjector injector = GWT.create(AppInjector.class);
public void onModuleLoad()
{
MainForm mf = injector.getMainPanel();
RootPanel.get().add(mf);
}
}
And the module xml file
<module rename-to="MySampleApplication">
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Specify the app entry point class. -->
<entry-point class='com.mySampleApplication.client.MySampleApplication'/>
<inherits name="com.google.gwt.inject.Inject"/>
<!-- Specify the app servlets. -->
<servlet path='/MySampleApplicationService' class='com.mySampleApplication.server.MySampleApplicationServiceImpl'/>
</module>
After i run this code i got an exception :
ERROR: Failed to create an instance of 'com.mySampleApplication.client.MySampleApplication' via def开发者_高级运维erred binding . java.lang.RuntimeException: Deferred binding failed for 'com.mySampleApplication.client.gin.AppInjector' (did you forget to inherit a required module?).
I tried with gin 1.0 and guice 2.0.
Please, advice.
Thanks.
@GinModules(AppClientModule.class)
should probably be
@GinModules(AppModule.class)
Update:
The error is in line declaring AppInjector
. It should be:
interface AppInjector extends Ginjector {
精彩评论