title: Spring Boot: The bean 'auditLogDao' could not be injected as a 'AuditLogDao' because it is a JDK dynamic proxy
body: <p>I am getting the following error in a Spring Boot project on which I work:</p>
  
  <blockquote>
    <p>The bean 'auditLogDao' could not be injected as a '{redactedpathwithcorporatename}.AuditLogDao' because it is a JDK dynamic proxy that implements:
        org.springframework.data.jpa.repository.JpaRepository</p>
    
    <p>Action:</p>
    
    <p>Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.</p>
  </blockquote>
  
  <p>I have tried a variety of solutions on StackOverflow without success, specifically:</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/39483059/transactional-annotation-error#answer-43715808">Checking that I am indeed calling the interface, not the implementation.</a></p></li>
  <li><p>Adding @Component to the top of SwitchUserFilter</p></li>
  <li><p>Changing @Resource to @Autowired. </p></li>
  </ol>
  
  <p><strong>AuditLogDao.java</strong></p>
  
  <pre><code>public interface AuditLogDao extends JpaRepository&lt;AuditLog, String&gt; {}
  </code></pre>
  
  <p><strong>AuditLogService.java</strong></p>
  
  <pre><code>public interface AuditLogService {
      AuditLog save(final AuditLog auditLog);
  }
  
  </code></pre>
  
  <p><strong>AuditLogServiceImplementation.java</strong></p>
  
  <pre><code>public class AuditLogServiceImplementation implements AuditLogService{
  
      @Resource private AuditLogDao auditLogDao;
  
      @Override
      public AuditLog save(AuditLog auditLog) {
          return auditLogDao.save(auditLog);
      }
  }
  </code></pre>
  
  <p>The file where I actually want to use the service to save information</p>
  
  <p><strong>SwitchuserFilter.java</strong></p>
  
  <pre><code>public class SwitchUserFilter
          extends org.springframework.security.web.authentication.switchuser.SwitchUserFilter {
      @Resource AuditLogService logService;
  '''
          logService.save(auditLog);
  '''
  }
  </code></pre>
  
  <p>I am relatively new to Spring Boot, so an explanation of why it fixes the problem would be appreciated. </p>