Code first:
@Slf4j
public class HelperModule extends AbstractModule
{
@Override
protected void configure()
{
}
@Provides
@Named("plugin")
@Singleton
public Reflections getReflections(@Nullable @Named("plugin-scope") String pluginScope)
{
if (pluginScope == null)
{
pluginScope = "me.wener";
}
log.info("Create plugin scanner for '{}'", pluginScope);
return new Reflections(new ConfigurationBuilder()
.setUrls(ClasspathHelper.forPackage(pluginScope))
.addScanners(
new SubTypesScanner(),
new TypeAnnotationsScanner())
// .filterInputsBy(new FilterBuilder().include(".*\\.java").exclude(".*"))
);
}
}
What I expected is pluginScope
can be null and optional, I follow the instruction Use @Nullable, but this is not works, I still got
No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=plugin-scope) was bound
What's wrong ?
EDIT
BTW,The @Nullable
is javax.annotation.Nullable