gpt4 book ai didi

java - 通过 GinModuleAdapter 在 GIN 应用程序上使用 Grapher

转载 作者:行者123 更新时间:2023-12-02 00:52:29 25 4
gpt4 key购买 nike

我一直在尝试使用Grapher在我的 GIN 项目上。但尝试创建一个 Injector 来提供 InjectorGrapher 却没有成功。

就在我的代码的第一行:

    Injector injector = Guice.createInjector( new GinModuleAdapter( new MyGinModule() ) );

它崩溃了

 Exception in thread "main" java.lang.AssertionError: should never be actually called
at com.google.gwt.inject.rebind.adapter.GwtDotCreateProvider.get(GwtDotCreateProvider.java:43)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:811)
at com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
at com.google.inject.Scopes$1$1.get(Scopes.java:54)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
at com.google.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
at com.google.inject.BoundProviderFactory.get(BoundProviderFactory.java:56)
at com.google.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:811)
at com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
at com.google.inject.Scopes$1$1.get(Scopes.java:54)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.InjectorBuilder$1.call(InjectorBuilder.java:200)
at com.google.inject.InjectorBuilder$1.call(InjectorBuilder.java:194)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
at com.google.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:194)
at com.google.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:176)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:113)
at com.google.inject.Guice.createInjector(Guice.java:92)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at com.me.myself.Grapher.main(Grapher.java:20)

什么给出了?

最佳答案

弄清楚:我的模块有以下行导致 GinModuleAdapter 阻塞(似乎是一个错误):

 bind(Foo.class).asEagerSingleton();

删除“asEagerSingleton”导致一切正常。但由于这不是我想要的,所以我将其转换成这样,这也有效。

@Provides @Singleton
Foo getFoo() {
return new Foo();
}

关于java - 通过 GinModuleAdapter 在 GIN 应用程序上使用 Grapher,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2431904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com