title: Spring AOP Autowiring exception
body: <p>I'm using AspectJ in my project.</p>
  
  <pre><code>@Aspect
  Class FooAsspectj{
  private static Logger log = LoggerFactory.getLogger(FooAsspectj.class);
  
  @Pointcut("execution(* com.abc.Foo.getFoo(..))")
  public void getFoo() { }
  
  @Around("getFoo()")
  public Object profileFoo(ProceedingJoinPoint pjp) throws Throwable {
      long start = System.currentTimeMillis();
      log.debug("Going to call the method.");
      Object output = pjp.proceed();
      log.debug("Method execution completed.");
      long elapsedTime = System.currentTimeMillis() - start;
      log.debug("Method execution time: " + elapsedTime + " milliseconds.");
      return output;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code> Class Foo{
  
      public void getFoo(String abc){
  
  System.out.println("Hello Foo");
      }
  </code></pre>
  
  <p>Now I have another class UseFoo, in which I'm autowiring Foo class</p>
  
  <pre><code>Class UseFoo{
  
  @Autowired
      private Foo foo;
  
  }
  </code></pre>
  
  <p>I have made following entries in ApplicationContext.xml</p>
  
  <pre><code>&lt;aop:aspectj-autoproxy /&gt;
  
  &lt;bean id="fooaspect" class="FooAsspectj" /&gt;
  </code></pre>
  
  <p>I'm getting error</p>
  
  <blockquote>
    <p>Caused by: org.springframework.beans.factory.BeanCreationException:
    Error creating bean with name 'useFoo':
    Injection of autowired dependencies failed; nested exception is
    org.springframework.beans.factory.BeanCreationException: Could not
    autowire field: private Foo
    UseFoo.foo;
    nested exception is java.lang.IllegalArgumentException: Can not set
    Foo field
    UseFoo.foo to
    $Proxy56</p>
  </blockquote>
  
  <p>If I remove <code>&lt;bean id="fooaspect" class="FooAsspectj" /&gt;</code> it works fine.</p>