Guice: differences between Singleton.class and @Singleton
问题 In Guice, what's the difference between: // Inside your AbstractModule subclass: @Override public void configure() { bind(Service.class).to(ServiceImpl.class).in(Singleton.class); } And: @Override public void configure() { bind(Service.class).to(ServiceImpl.class); } @Provides @Singleton public ServiceImpl providesService() { return new ServiceImpl(); } Are they both the same? When would you use one versus the other? Thanks in advance. 回答1: They are nearly identical. The @Singleton syntax is