使用多个 AbstractGinModule 实例化注入器

发布于 2024-08-07 18:55:05 字数 200 浏览 12 评论 0原文

在 google Guice 中,我可以使用函数 createInjector 创建基于多个模块的注入器。

因为我在GoogleGin中使用GWT.create来实例化注入器,所以是否可以基于多个AbstractGinModule创建一个Ginjector。

如果不能,您如何组织代码以避免所有绑定都在同一个 Module 中?

In google Guice, I can create an injector based on multiple module with the function createInjector.

Because I use GWT.create to instanciate the injector in GoogleGin, is it possible to create a Ginjector based on multiple AbstractGinModule.

If we can't, how do you organize your code to avoid having all your binding in the same Module ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情独悲 2024-08-14 18:55:05

我使用以下代码创建使用多个模块的注入器:

@GinModules({ ClientDispatchModule.class, MyClientModule.class })
public interface MyAppGinjector extends Ginjector {

    AppPresenter getAppPresenter();

    PlaceManager getPlaceManager();

    EventBus getEventBus();
}

I use the following code to create injector which is using multiple modules:

@GinModules({ ClientDispatchModule.class, MyClientModule.class })
public interface MyAppGinjector extends Ginjector {

    AppPresenter getAppPresenter();

    PlaceManager getPlaceManager();

    EventBus getEventBus();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文