Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why there is two instances of a singleton with Google Guice dependency injection framework

There’s 2 Singleton instances, both created by Google Guice, in my application.

How’s that even possible?

The binding is done as follow:

bind(Foo.class).to(FooImpl.class).in(Scopes.SINGLETON);
like image 282
Pier-Alexandre Bouchard Avatar asked Oct 07 '22 13:10

Pier-Alexandre Bouchard


1 Answers

The problem here was the binding declaration.

We fixed it by replacing the binding declaration to:

bind(FooImpl.class).in(Scopes.SINGLETON);
bind(Foo.class).to(FooImpl.class); 
like image 142
Pier-Alexandre Bouchard Avatar answered Oct 10 '22 09:10

Pier-Alexandre Bouchard