title: Spring Bean implements interface
body: <pre><code>public interface Service {
  
    public void doSomething();
  }
  
  @Service
  public class MyService implements service{
  
        @Transactional 
        public void doSomething(){
        }
  }
  
  @Controller
  public class MyController {
  
    @Autowired
    private MyService service;
  }
  </code></pre>
  
  <p>In above scenario autowiring fails with exception "<code>illegalArgumentException : argument type mismatch</code>". When I remove <code>implements service</code> from MyService everything works fine.</p>
  
  <p>I have searched and found that place <code>&lt;aop:aspectj-autoproxy proxy-target-class="true"/&gt;</code> in applicationContext.xml for successful autowiring and it worked. 
  I have also found that spring uses JDK proxy when @Transactional is used.</p>
  
  <p>I have some confusions,</p>
  
  <ol>
  <li>How @Transactional relates to Proxying</li>
  <li>Why spring uses JDK Proxy for the beans which implements interfaces. </li>
  <li>Why I need to place <code>&lt;aop:aspectj-autoproxy proxy-target-class="true"/&gt;</code> in applicationContext.xml </li>
  </ol>
  
  <p>Can anyone please explain ? or refer me any article or blog</p>