Some of my modules require a binding from another module.  I want to set up 
a requireBinding in the dependent modules' configure() method, but it 
doesn't seem to be working for me.  Here is an example of what I am doing:

@interface MyMap {

class ModuleA extends AbstractModule {
    protected void configure() {

    static def Map<String, String> myMap() {
                [A: 'val1',
                 B: 'val2']

class ModuleB extends AbstractModule {
    protected void configure() {
        requireBinding(Key.get(Map, MyMap))
        bind Foo

class ModuleIT extends Specification {
    def 'Test module configuration'() {
        def injector = Guice.createInjector new ModuleA(), new ModuleB()

        def result = injector.getInstance Foo

        result instanceof Foo
        result.someMap instanceof Map<String, String>

This results in an error when createInjector is called: Unable to create injector, see the 
following errors:
1) No implementation for java.util.Map annotated with interface a.b.c.MyMap 
was bound.

On the other hand, it works fine if I don't specify requreBinding.  
However, since this dependent module has no notion of the map that is 
bound, I want to ensure that the binding is present when the dependent 
module is created.

You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

Reply via email to