title: Spring Boot: How to declare a custom repository factory bean
body: <p>I'm using <em>Spring Boot (1.3.3)</em> with annotation-based/JavaConfig configuration on an application.
  I have the following repository interface:</p>
  
  <pre><code>@RepositoryRestResource(collectionResourceRel = "something", path = "something")
  public interface SomethingRepository 
      extends CrudRepository&lt;SomethingRepository, Long&gt; {
  
  }
  </code></pre>
  
  <p>What I would like to do is override the behavior of some methods in the generated repository proxy. The only way I found of doing this is based on what the documentation suggests for adding new custom methods (see: <a href="http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.single-repository-behaviour" rel="nofollow">Adding custom behavior to single repositories</a>), so I define the following interface:</p>
  
  <pre><code>public interface SomethingRepositoryCustom {
      Something findOne(Long id);
  }
  </code></pre>
  
  <p>...and I add the corresponding implementation:</p>
  
  <pre><code>public SomethingRepositoryImpl extends SimpleJpaRepository&lt;Something, Long&gt; 
      implements SomethingRepositoryCustom {
  
      public SomethingRepositoryImpl(&lt;Something&gt; domainClass, EntityManager em) {
          super(domainClass, em);
          this.entityManager = em;
      }
  
      @Override
      public Something findOne(Long id) {
          System.out.println("custom find one");
          // do whatever I want and then fetch the object
          return null;
      }
  
  }
  </code></pre>
  
  <p>Now, if I start the application, I get the following error:</p>
  
  <blockquote>
    <p>... org.springframework.beans.BeanInstantiationException: Failed to
    instantiate [com.dummy.repositories.SomethingRepositoryImpl]: No
    default constructor found; nested exception is
    java.lang.NoSuchMethodException:
    com.dummy.repositories.SomethingRepositoryImpl.() ...</p>
  </blockquote>
  
  <p><strong>Question:</strong>
  How can I solve the BeanInstantiationException? I'm assuming I need to declare a repository factory bean but I'm not sure how to do so overriding the Spring Boot configuration.</p>