title: spring autowired aop circular dependency
body: <p>I'm using java config with <code>@ComponentScan</code>in order to initialize my beans
  and <code>@EnableAspectJAutoProxy(proxyTargetClass=true)</code>to use cglib proxies.</p>
  
  <p>In this project we have a lots of generated services autowired between them using <code>@Autowired</code>. It works pretty well.</p>
  
  <p>But, for some of these services I've added <code>@Async</code> (I've also added <code>@EnableAsync(proxyTargetClass = true)</code>on my <code>@Configuration</code>class).</p>
  
  <p>After that, I'm getting:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'ConversationUserLocalService': Bean with name 'ConversationUserLocalService' has been injected into other beans [ConversationUserHistoryLocalService] i
  n its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'a
  llowEagerInit' flag turned off, for example.
  </code></pre>
  
  <p>I guess this is because Spring is injecting the service with <code>@Async</code>method BEFORE AOP creates the proxy.
  Could this be the problem?
  How I should fix it? </p>
  
  <p>In order to try to clarify my problem, let's say I have:</p>
  
  <p>@Service A, B &amp; C;</p>
  
  <p>A has autowired B &amp; C, B has autowired A &amp; C, C has autowired A &amp; B;</p>
  
  <p>C has a method marked as @Async.</p>
  
  <p>When Spring initialize applicationContext, it tries to initialize A, but needs B &amp; C, so it initializes them. But after all, AOP tries to make a proxy of C (because @Async) and then it detects that autowired C into B and A is not the same as proxy of C so it fails.</p>
  
  <p>I hope this can explain a little more what is happening.</p>