Open gissuebot opened 10 years ago
I got this message for another link too: https://github.com/google/guice/issues/139. First of all I think that the @Inject doesn't refer to concrete classes and yes, interfaces only. I guess that the message have to improve to:
Tried proxying projectGuiceTest.A to support a circular dependency, but it is not an interface. You have to break the circular dependency, or make the circular dependency refers to interfaces.
In this way I think that we clarify more the user who will make the best decision.
I will made the changes to improve it.
From stepan.koltsov on March 07, 2012 14:42:18
public static class A { private final B b;
@
Inject public A(B b) { this.b = b; } }public static class B { private A a;
@
Inject public void setA(A a) { this.a = a; } }public static void main(String[] args) { Guice.createInjector(new AbstractModule() {
@
Override protected void configure() { } }).getInstance(A.class);}
guice reports error:
Tried proxying com.company.Temp$A to support a circular dependency, but it is not an interface
Proxy is not needed here: guice should just create "B" first, inject it into "A" constructor and then inject "A" into "B".
Original issue: http://code.google.com/p/google-guice/issues/detail?id=690