gpt4 book ai didi

java - 为什么我们需要在 Guice 模块中实现configure()?

转载 作者:行者123 更新时间:2023-12-01 19:39:10 27 4
gpt4 key购买 nike

我有以下代码:

public class XYZModule extends AbstractModule {

@Override
protected void configure() {
}

@Provides
@Singleton
private XYZ provideXYZ() {
return new XYZ(1, 2);
}
}

空的configure()方法在这里有什么作用吗?

最佳答案

你不再需要它了

Guice 4.2 , the configure() method isn't abstract不再了。因此,如果您不使用它,可以在模块中删除它。以下是发行说明对此的描述:

AbstractModule.configure() is non-abstract to allow modules with only @Provides/@ProvidesIntoSet/... methods.

关于java - 为什么我们需要在 Guice 模块中实现configure()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55977616/

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