为什么我们需要在 Guice 模块中实现 configure()?
Why do we need to implement configure() in Guice Modules?
我有以下代码:
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.
我有以下代码:
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.