title: How to call Spring Framework repositories methods
body: <p>I know that there are questions similar to this one, but none of them have helped me. I'm following along <a href="https://spring.io/guides/gs/accessing-data-jpa/" rel="nofollow noreferrer">this tutorial</a>, and the part I can't wrap my mind around is:</p>
  
  <pre><code>@SpringBootApplication
  public class Application {
  
      private static final Logger log = 
      LoggerFactory.getLogger(Application.class);
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class);
      }
  
      @Bean
      public CommandLineRunner demo(CustomerRepository repository) {
          return (args) -&gt; {
              // save a couple of customers
              ...
              // more lines, etc...
  </code></pre>
  
  <p>What I don't understand is <em>where</em> the <code>repository</code> passed into <code>demo</code> comes from. I know that the <code>Autowired</code> annotation can do something like that, but it isn't used at all here.</p>
  
  <p>The more specific reason I ask is because I'm trying to adapt what they do here to an application I'm working on. I have a class, separate from all of the persistence/repository stuff, and I want to call repository methods like <code>save</code> and <code>findAll</code>. The issue is that the repository is an <code>interface</code>, so I can't instantiate an object of it to call the methods. So do I have to make a new class that <code>implements</code> the interface and create an object of that? Or is there an easier way using annotations?</p>