title: How to define a bean for an (non-static) inner class in Spring? Avoiding circular dependency
body: <p>I am having a class with an inner class like this:</p>
  
  <pre><code>package myPackage;
  
  public class A {
      private B b;
  
      public void setB(B b) { this.b = b; }
      public B getB() { return this.b; }
  
      public class B {
      }
  }
  </code></pre>
  
  <p>And I have my spring configuration as follow:</p>
  
  <pre><code>&lt;bean id="a" class="myPackage.A" autowire="byName" scope="prototype"&gt;
      &lt;property name="b"&gt;
          &lt;bean class="myPackage.A$B" name="b" autowire="byName" scope="prototype"&gt;
              &lt;constructor-arg ref="a"/&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>But I am facing this error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'a': Requested bean is currently in creation: Is there an unresolvable circular reference?
  </code></pre>
  
  <p>Of course it is obvious that I am having a circular reference, but how can I have a spring bean for my inner class?</p>