Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Google/Guice中的BindaContract等价物_Java_Guice_Hk2 - Fatal编程技术网

Java Google/Guice中的BindaContract等价物

Java Google/Guice中的BindaContract等价物,java,guice,hk2,Java,Guice,Hk2,有人能给我指一下谷歌Guice中相当于HK2的bindAsContract吗 香港2的例子: public static class Binder extends AbstractBinder { @Override protected void configure() { bindAsContract(MyClass.Factory.class).in(Singleton.class); } } 我已经有一段时间没有使用guice了,但是AFAICR,

有人能给我指一下谷歌Guice中相当于HK2的bindAsContract吗

香港2的例子:

public static class Binder extends AbstractBinder {
    @Override
    protected void configure() {
        bindAsContract(MyClass.Factory.class).in(Singleton.class);
    }
}

我已经有一段时间没有使用guice了,但是AFAICR,你不能用guice单独使用
bind
bindacontact
只是
bind(Some.class).to(Some.class)
的缩写。也许我错了,但我认为这就是
bind
本身在guice中的作用,如果您使用的是
AbstractModule
您是否尝试过
bind(MyClass.Factory.class).in(Singleton.class)
?是的,我想我应该关闭这个。我最终使用了
bind(MyClass.Factory.class).in(Singleton.class)
。请随便回答,我会接受的。谢谢,我已经有一段时间没有使用guice了,但是AFAICR,你不能用guice单独使用
bind
bindacontact
只是
bind(Some.class).to(Some.class)
的缩写。也许我错了,但我认为这就是
bind
本身在guice中的作用,如果您使用的是
AbstractModule
您是否尝试过
bind(MyClass.Factory.class).in(Singleton.class)
?是的,我想我应该关闭这个。我最终使用了
bind(MyClass.Factory.class).in(Singleton.class)
。请随便回答,我会接受的。谢谢