Pier-Alexandre Bouchard
Pier-Alexandre Bouchard

Reputation: 5235

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);

Upvotes: 6

Views: 2545

Answers (1)

Pier-Alexandre Bouchard
Pier-Alexandre Bouchard

Reputation: 5235

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); 

Upvotes: 5

Related Questions