title: Get 'Specified class is an interface' while run the file
body: <p>I got this error while run the .sh file :</p>
  
  <pre><code>Error creating bean with name 'frdParameterRule2DAO' defined in class path resource [com/.../beans.xml]: 
  Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
  Could not instantiate bean class [com.....dao.FrdParameterRule2DAO]: Specified class is an interface
  </code></pre>
  
  <p>This is the code that file .sh execute (I omitted unnecessary code) :</p>
  
  <pre><code>public final class FraudCacheBatchJob {
      private static final String CLASS_NAME = FraudCacheBatchJob.class.getCanonicalName();
      private static final String CONTEXT_XML_NAME = "/beans.xml";
  
      private static String getPackageLocation() {
          return FraudCacheBatchJob.class.getPackage().getName().replace(".", "/");
      }
  
      public static void main(String[] args) {
          try {
              ApplicationContext context = new ClassPathXmlApplicationContext(getPackageLocation() + CONTEXT_XML_NAME);
  
              CachedRule cachedRule = context.getBean("cachedRule", CachedRule.class);
  
              cachedRule.getCacheRule2();
          } catch (Exception ex) {
          }
      }
  }
  </code></pre>
  
  <p><code>CachedRule</code> :</p>
  
  <pre><code>public interface CachedRule {
      void getCacheRule2();
  
      ...
  }
  </code></pre>
  
  <p><code>CachedRuleImpl</code> :</p>
  
  <pre><code>@Service("CachedRule")
  public class CachedRuleImpl implements CachedRule {
      @Autowired
      FrdParameterRule2DAO frdParameterRule2DAO;
  
      @Cacheable(value = "ruleCache", key = "'cache-getFrdRule2'")
      public void getCacheRule2() {
          frdParameterRule2DAO.findAll();
      }
  
      ...
  }
  </code></pre>
  
  <p><code>FrdParameterRule2DAO</code> :</p>
  
  <pre><code>public interface FrdParameterRule2DAO extends JpaRepository&lt;parameterRule, Long&gt; {
      ...
  }
  </code></pre>
  
  <p><code>beans.xml</code> :</p>
  
  <pre><code>&lt;bean id="frdParameterRule2DAO" class="com.....dao.FrdParameterRule2DAO"&gt;&lt;/bean&gt;
  &lt;bean id="cachedRule" class="com.....spring.fraud.rule.CachedRuleImpl"&gt;
      &lt;property name="frdParameterRule2DAO" ref="frdParameterRule2DAO" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>While I tried to change the DAO to <code>public class</code>, I got error : </p>
  
  <pre><code>The type JpaRepository&lt;FrdParameterRule2,Long&gt; cannot be the superclass of FrdParameterRule2DAO; a superclass must be a class
  </code></pre>
  
  <p>What should I do? Thanks.</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I tried this (@StanislavL) :</p>
  
  <p><code>FrdParameterRule2DAO</code> :</p>
  
  <pre><code>@Repository
  public interface FrdParameterRule2DAO extends JpaRepository&lt;parameterRule, Long&gt; {
      ...
  }
  </code></pre>
  
  <p><code>beans.xml</code> :</p>
  
  <pre><code>&lt;!-- &lt;bean id="frdParameterRule2DAO" class="com.....dao.FrdParameterRule2DAO"&gt;&lt;/bean&gt; --&gt;
  &lt;bean id="cachedRule" class="com.....spring.fraud.rule.CachedRuleImpl"&gt;
      &lt;property name="frdParameterRule2DAO" ref="frdParameterRule2DAO" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>but then get : </p>
  
  <pre><code>Error creating bean with name 'cachedRule' defined in class path resource [com/.../beans.xml]: Cannot resolve reference to bean 'frdParameterRule2DAO' while setting bean property 'frdParameterRule2DAO'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'frdParameterRule2DAO' is defined
  </code></pre>