title: Is it possible to unproxy a Spring bean?
body: <p>I have a Spring bean, let's say:</p>
  
  <pre><code>@TransactionAttribute(TransactionAttributeType.REQUIRED) 
  public class AImpl implements A {
  
       public void setSomeDependency(D dependency) {
           // This setter DOES NOT BELONG to interface A
       }
  }
  
  &lt;bean id="aImpl" class="AImpl"/&gt;
  </code></pre>
  
  <p>Now I want to integration test it, but first I need to mock the dependency <code>D</code>, because it does too much stuff. Since the <code>AImpl</code> implements an interface and contains a transactional annotation, the generated proxy is only compatible with the interface <code>A</code>, so I can do this:</p>
  
  <pre><code>@Inject @Named("aImpl")
  private A a;
  </code></pre>
  
  <p>but cannot:</p>
  
  <pre><code>@Inject @Named("aImpl")
  private AImpl a;
  </code></pre>
  
  <p>As a result, I can't mock my dependency.</p>
  
  <p>Please note that adding <code>void setSomeDependency(D dependency)</code> to interface <code>A</code> is not an option, as it has no business meaning. Neither it is using the <code>proxy-target-class="true"</code>, as it breaks a whole lot of other beans (this attribute affects all beans in the context).</p>
  
  <p>Is there a way to unproxy the injected bean <code>A</code>, so I could cast it to <code>AImpl</code>?</p>