@@ -0,0 +1,1343 @@
+package guice.config;%0A%0Aimport java.util.Map;%0A%0Aimport com.google.inject.AbstractModule;%0Aimport com.google.inject.Binding;%0Aimport com.google.inject.Guice;%0Aimport com.google.inject.Injector;%0Aimport com.google.inject.Key;%0Aimport com.google.inject.name.Names;%0Aimport guice.config.demo.Hello;%0Aimport guice.config.demo.HelloA;%0Aimport guice.config.demo.HelloB;%0A%0A/**%0A * @author %3Ca href=%22mailto:gang.lvg@alibaba-inc.com%22%3Ekimi%3C/a%3E 2017-08-03%0A */%0Apublic class InjectorNamedTest %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        final Injector injector = Guice.createInjector(new AbstractModule() %7B%0A            @Override%0A            protected void configure() %7B%0A                bind(Hello.class).annotatedWith(Names.named(%22a%22)).to(HelloA.class);%0A                bind(Hello.class).annotatedWith(Names.named(%22b%22)).to(HelloB.class);%0A            %7D%0A        %7D);%0A%0A        Hello hello = injector.getInstance(Key.get(Hello.class, Names.named(%22a%22)));%0A        System.out.println(hello);%0A        hello = injector.getInstance(Key.get(Hello.class, Names.named(%22b%22)));%0A        System.out.println(hello);%0A%0A        final Map%3CKey%3C?%3E, Binding%3C?%3E%3E bindings = injector.getBindings();%0A        for (Map.Entry%3CKey%3C?%3E, Binding%3C?%3E%3E entry : bindings.entrySet()) %7B%0A            System.out.println(entry.getKey() + %22 --%3E %22 + entry.getValue());%0A        %7D%0A    %7D%0A%0A%7D%0A

add unit test